1 #ifndef __DALI_SOUND_PLAYER_H__
2 #define __DALI_SOUND_PLAYER_H__
5 * Copyright (c) 2018 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-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
26 #include <dali/public-api/dali-adaptor-common.h>
31 namespace Internal DALI_INTERNAL
40 * @brief Plays sound effects.
42 class DALI_ADAPTOR_API SoundPlayer : public BaseHandle
46 typedef Signal< void (SoundPlayer&) > SoundPlayFinishedSignalType; ///< Sound play finished signal
49 * @brief Create an uninitialized handle.
51 * This can be initialized by calling SoundPlayer::Get().
56 * @brief Create an initialized handle to the SoundPlayer.
58 * @return A handle to a newly allocated Dali resource.
60 static SoundPlayer Get();
65 * This is non-virtual since derived Handle types must not contain data or virtual methods.
70 * @brief Plays a sound file.
72 * @pre The SoundPlayer needs to be initialized.
73 * @param[in] fileName Path to the sound file to play.
74 * @return a handle to the currently playing sound file which can be used to stop.
76 int PlaySound(const std::string fileName);
79 * @brief Stops the currently playing sound.
81 * @pre The SoundPlayer needs to be initialized.
84 void Stop(int handle);
87 * @brief This signal will be emitted after a given sound file is completely played.
89 * @pre The SoundPlayer needs to be initialized.
90 * @return The signal to connect to.
92 * @note The signal name is "soundPlayFinished" if using BaseHandle::ConnectSignal()
94 SoundPlayFinishedSignalType& SoundPlayFinishedSignal();
96 public: // Not intended for application developers
99 * @brief This constructor is used by SoundPlayer::Get().
101 * @param[in] soundPlayer A pointer to the sound player.
103 explicit DALI_INTERNAL SoundPlayer( Internal::Adaptor::SoundPlayer* soundPlayer );
108 #endif // __DALI_SOUND_PLAYER_H__