[dali_1.0.1] Merge branch 'tizen'
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / sound-player.h
1 #ifndef __DALI_SOUND_PLAYER_H__
2 #define __DALI_SOUND_PLAYER_H__
3
4 /*
5  * Copyright (c) 2014 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 /**
22  * @addtogroup CAPI_DALI_ADAPTOR_MODULE
23  * @{
24  */
25
26 // EXTERNAL INCLUDES
27 #include <dali/public-api/object/base-handle.h>
28 #include <dali/public-api/signals/dali-signal-v2.h>
29
30 namespace Dali DALI_IMPORT_API
31 {
32
33 namespace Internal DALI_INTERNAL
34 {
35 namespace Adaptor
36 {
37 class SoundPlayer;
38 }
39 }
40
41 /**
42  * @brief Plays sound effects.
43  */
44 class SoundPlayer : public BaseHandle
45 {
46 public:
47
48   typedef SignalV2< void (SoundPlayer&) > SoundPlayFinishedSignalV2; ///< Sound play finished signal
49
50   // Signal Names
51   static const char* const SIGNAL_SOUND_PLAY_FINISHED; ///< name "sound-play-finished"
52
53 public:
54
55   /**
56    * @brief Create an uninitialized handle.
57    *
58    * This can be initialized by calling SoundPlayer::Get().
59    */
60   SoundPlayer();
61
62   /**
63    * @brief Create an initialized handle to the SoundPlayer.
64    *
65    * @return A handle to a newly allocated Dali resource.
66    */
67   static SoundPlayer Get();
68
69   /**
70    * @brief Destructor
71    *
72    * This is non-virtual since derived Handle types must not contain data or virtual methods.
73    */
74   ~SoundPlayer();
75
76   /**
77    * @brief Plays a sound file.
78    *
79    * @pre The SoundPlayer needs to be initialized.
80    * @param[in]  fileName Path to the sound file to play.
81    * @return a handle to the currently playing sound file which can be used to stop.
82    */
83   int PlaySound(const std::string fileName);
84
85   /**
86    * @brief Stops the currently playing sound.
87    *
88    * @pre The SoundPlayer needs to be initialized.
89    * @param[in] handle
90    */
91   void Stop(int handle);
92
93   /**
94    * @brief This signal will be emitted after a given sound file is completely played.
95    *
96    * @pre The SoundPlayer needs to be initialized.
97    * @return The signal to connect to.
98    */
99   SoundPlayFinishedSignalV2& SoundPlayFinishedSignal();
100
101 public: // Not intended for application developers
102
103   /**
104    * @brief This constructor is used by SoundPlayer::Get().
105    *
106    * @param[in] soundPlayer A pointer to the sound player.
107    */
108   SoundPlayer( Internal::Adaptor::SoundPlayer* soundPlayer );
109 };
110
111 } // namespace Dali
112
113 /**
114  * @}
115  */
116 #endif // __DALI_SOUND_PLAYER_H__