cc7598d28d72b31f75c6175ca6ec7d2fcf0f7877
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / feedback-player.h
1 #ifndef DALI_FEEDBACK_PLAYER_H
2 #define DALI_FEEDBACK_PLAYER_H
3
4 /*
5  * Copyright (c) 2019 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
24 // INTERNAL INCLUDES
25 #include <dali/public-api/dali-adaptor-common.h>
26
27 namespace Dali
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 namespace Adaptor
33 {
34 class FeedbackPlayer;
35 }
36 }
37
38 /**
39  * @brief Plays feedback effects.
40  */
41 class DALI_ADAPTOR_API FeedbackPlayer : public BaseHandle
42 {
43 public:
44
45   /**
46    * @brief Create an uninitialized handle.
47    *
48    * This can be initialized by calling FeedbackPlayer::Get().
49    */
50   FeedbackPlayer();
51
52   /**
53    * @brief Create an initialized handle to the FeedbackPlayer.
54    *
55    * @return A handle to a newly allocated Dali resource.
56    */
57   static FeedbackPlayer Get();
58
59   /**
60    * @brief Destructor
61    *
62    * This is non-virtual since derived Handle types must not contain data or virtual methods.
63    */
64   ~FeedbackPlayer();
65
66   /**
67    * @brief Plays a monotone vibration.
68    * @param[in]  duration  The duration of the vibration.
69    */
70   void PlayMonotone(unsigned int duration);
71
72   /**
73    * @brief Plays vibration in predefined patterns.
74    * @param[in] filePath Path to the file containing the effect.
75    */
76   void PlayFile(const std::string filePath);
77
78   /**
79    * @brief Stops the currently playing vibration effects.
80    */
81   void Stop();
82
83   /**
84    * Plays a sound file.
85    * @param[in] fileName Path to the sound file to play.
86    * @return A handle which can be used to stop the sound playback.
87    */
88   int PlaySound( const std::string& fileName );
89
90   /**
91    * Stops a currently playing sound.
92    * @param[in] handle A handle to the currently playing sound.
93    */
94   void StopSound( int handle );
95
96   /**
97    * Plays a feedback pattern.
98    * @param[in] type The type of feedback.
99    * @param[in] pattern The ID of the pattern to play.
100    */
101   void PlayFeedbackPattern( int type, int pattern );
102
103   /*
104    * Loads a file into data
105    * @param[in] filename The filename.
106    * @param[in] data The data in the file.
107    * @return True if the file data could be loaded
108    */
109   bool LoadFile(const std::string& filename, std::string& data);
110
111 public: // Not intended for application developers
112
113   /**
114    * @brief This constructor is used by FeedbackPlayer::Get().
115    * @param[in] feedbackPlayer A pointer to the feedback player.
116    */
117   explicit DALI_INTERNAL FeedbackPlayer( Internal::Adaptor::FeedbackPlayer* feedbackPlayer );
118 };
119
120 } // namespace Dali
121
122 #endif // DALI_FEEDBACK_PLAYER_H