2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <haptic-player-impl.h>
22 #include <dali/public-api/object/type-registry.h>
25 #include <adaptor-impl.h>
36 namespace // unnamed namespace
40 Dali::BaseHandle Create()
42 return HapticPlayer::Get();
45 Dali::TypeRegistration HAPTIC_PLAYER_TYPE( typeid(Dali::HapticPlayer), typeid(Dali::BaseHandle), Create );
47 } // unnamed namespace
49 Dali::HapticPlayer HapticPlayer::New()
51 Dali::HapticPlayer player = Dali::HapticPlayer( new HapticPlayer() );
55 Dali::HapticPlayer HapticPlayer::Get()
57 Dali::HapticPlayer player;
59 if ( Adaptor::IsAvailable() )
61 // Check whether the singleton is already created
62 Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::HapticPlayer ) );
65 // If so, downcast the handle
66 player = Dali::HapticPlayer( dynamic_cast< HapticPlayer* >( handle.GetObjectPtr() ) );
70 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
71 player = Dali::HapticPlayer( New() );
72 adaptorImpl.RegisterSingleton( typeid( player ), player );
79 void HapticPlayer::PlayMonotone( unsigned int duration )
81 mPlugin.PlayHapticMonotone( duration );
84 void HapticPlayer::PlayFile( const std::string& filePath )
86 mPlugin.PlayHaptic( filePath );
89 void HapticPlayer::Stop()
94 HapticPlayer::HapticPlayer()
95 : mPlugin( FeedbackPluginProxy::DEFAULT_OBJECT_NAME )
99 HapticPlayer::~HapticPlayer()
103 } // namespace Adaptor
105 } // namespace Internal