1 #ifndef DALI_INTERNAL_SOUND_PLAYER_H
2 #define DALI_INTERNAL_SOUND_PLAYER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-object.h>
26 #include <dali/devel-api/adaptor-framework/sound-player.h>
27 #include <dali/internal/haptics/common/feedback-plugin-proxy.h>
36 * Plays haptic effects.
38 class SoundPlayer : public Dali::BaseObject
41 typedef Dali::SoundPlayer::SoundPlayFinishedSignalType SoundPlayFinishedSignalType;
44 * Create a SoundPlayer.
45 * @return A newly created SoundPlayer.
47 static Dali::SoundPlayer New();
50 * Retrieve a handle to the SoundPlayer. This creates an instance if none has been created.
51 * @return A handle to the SoundPlayer.
53 static Dali::SoundPlayer Get();
56 * @copydoc Dali::SoundPlayer::PlaySound()
58 int PlaySound(const std::string fileName);
61 * @copydoc Dali::SoundPlayer::Stop()
63 void Stop(int handle);
66 * @copydoc Dali::SoundPlayer::SoundPlayFinishedSignal()
68 SoundPlayFinishedSignalType& SoundPlayFinishedSignal();
71 * Connects a callback function with the object's signals.
72 * @param[in] object The object providing the signal.
73 * @param[in] tracker Used to disconnect the signal.
74 * @param[in] signalName The signal to connect to.
75 * @param[in] functor A newly allocated FunctorDelegate.
76 * @return True if the signal was connected.
77 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
79 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
83 * Private Constructor; see also soundPlayer::New()
84 * @param[in] soundPlayer The public sound player class
91 ~SoundPlayer() override;
94 * Emits the SoundPlayFinished signal.
96 void EmitSoundPlayFinishedSignal();
99 SoundPlayer(const SoundPlayer&);
102 SoundPlayer& operator=(SoundPlayer&);
105 FeedbackPluginProxy mPlugin;
106 SoundPlayFinishedSignalType mSoundPlayFinishedSignal;
109 } // namespace Adaptor
111 } // namespace Internal
113 // Helpers for public-api forwarding methods
115 inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
117 DALI_ASSERT_ALWAYS(player && "SoundPlayer handle is empty");
119 BaseObject& handle = player.GetBaseObject();
121 return static_cast<Internal::Adaptor::SoundPlayer&>(handle);
124 inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
126 DALI_ASSERT_ALWAYS(player && "SoundPlayer handle is empty");
128 const BaseObject& handle = player.GetBaseObject();
130 return static_cast<const Internal::Adaptor::SoundPlayer&>(handle);
135 #endif // DALI_INTERNAL_SOUND_PLAYER_H