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