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