[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / sound-player.h
1 #ifndef DALI_SOUND_PLAYER_H
2 #define DALI_SOUND_PLAYER_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 namespace Internal DALI_INTERNAL
31 {
32 namespace Adaptor
33 {
34 class SoundPlayer;
35 }
36 } // namespace DALI_INTERNAL
37
38 /**
39  * @brief Plays sound effects.
40  */
41 class DALI_ADAPTOR_API SoundPlayer : public BaseHandle
42 {
43 public:
44   typedef Signal<void(SoundPlayer&)> SoundPlayFinishedSignalType; ///< Sound play finished signal
45
46   /**
47    * @brief Create an uninitialized handle.
48    *
49    * This can be initialized by calling SoundPlayer::Get().
50    */
51   SoundPlayer();
52
53   /**
54    * @brief Create an initialized handle to the SoundPlayer.
55    *
56    * @return A handle to a newly allocated Dali resource.
57    */
58   static SoundPlayer Get();
59
60   /**
61    * @brief Destructor
62    *
63    * This is non-virtual since derived Handle types must not contain data or virtual methods.
64    */
65   ~SoundPlayer();
66
67   /**
68    * @brief Plays a sound file.
69    *
70    * @pre The SoundPlayer needs to be initialized.
71    * @param[in]  fileName Path to the sound file to play.
72    * @return a handle to the currently playing sound file which can be used to stop.
73    */
74   int PlaySound(const std::string fileName);
75
76   /**
77    * @brief Stops the currently playing sound.
78    *
79    * @pre The SoundPlayer needs to be initialized.
80    * @param[in] handle
81    */
82   void Stop(int handle);
83
84   /**
85    * @brief This signal will be emitted after a given sound file is completely played.
86    *
87    * @pre The SoundPlayer needs to be initialized.
88    * @return The signal to connect to.
89    *
90    * @note The signal name is "soundPlayFinished" if using BaseHandle::ConnectSignal()
91    */
92   SoundPlayFinishedSignalType& SoundPlayFinishedSignal();
93
94 public: // Not intended for application developers
95   /**
96    * @brief This constructor is used by SoundPlayer::Get().
97    *
98    * @param[in] soundPlayer A pointer to the sound player.
99    */
100   explicit DALI_INTERNAL SoundPlayer(Internal::Adaptor::SoundPlayer* soundPlayer);
101 };
102
103 } // namespace Dali
104
105 #endif // DALI_SOUND_PLAYER_H