9c74a7f78562104f5137eba1e4321cd3ec7537b7
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / video-view / video-view.h
1 #ifndef __DALI_TOOLKIT_VIDEO_VIEW_H__
2 #define __DALI_TOOLKIT_VIDEO_VIEW_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32   class VideoView;
33 } // namespace Internal
34
35 /**
36  * @addtogroup dali_toolkit_controls_video_view
37  * @{
38  */
39
40 /**
41  * @brief VideoView is a control for video playback and display.
42  *
43  * For working VideoView, a video plugin for a platform should be provided.
44  *
45  * Signals
46  * | %Signal Name  | Method                  |
47  * |---------------|-------------------------|
48  * | finished      | @ref FinishedSignal()   |
49  * @SINCE_1_1.38
50  *
51  * Actions
52  * | %Action Name    | Attributes                                         | Description                                             |
53  * |-----------------|----------------------------------------------------|---------------------------------------------------------|
54  * | videoPlay       | Doesn't have attributes                            | Plays video. See @ref DoAction()                        |
55  * | videoPause      | Doesn't have attributes                            | Pauses video. See @ref DoAction()                       |
56  * | videoStop       | Doesn't have attributes                            | Stops video. See @ref DoAction()                        |
57  * | videoForward    | The position ( millisecond ) for forward playback  | Sets forward position for playback. See @ref DoAction() |
58  * | videoBackward   | The position ( millisecond ) for backward playback | Sets backward position for playback. See @ref DoAction()|
59  * @SINCE_1_1.38
60  *
61  */
62 class DALI_IMPORT_API VideoView: public Control
63 {
64 public:
65
66   // Signal
67   typedef Signal< void (VideoView&) > VideoViewSignalType; ///< Video playback finished signal type @ SINCE_1_1.38
68
69 public:
70
71   /**
72    * @brief Enumeration for the start and end property ranges for this control.
73    * @SINCE_1_0.0
74    */
75   enum PropertyRange
76   {
77     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,  ///< @SINCE_1_0.0
78   };
79
80   struct Property
81   {
82     enum
83     {
84       /**
85        * @brief name "video", video file url as string type or Property::Map.
86        * @SINCE_1_1.38
87        */
88       VIDEO = PROPERTY_START_INDEX,
89
90      /**
91        * @brief name "looping", looping status, true or false.
92        * @SINCE_1_1.38
93        */
94       LOOPING,
95
96      /**
97        * @brief name "muted", mute status, true or false.
98        * @SINCE_1_1.38
99        */
100       MUTED,
101
102      /**
103        * @brief name "volume", left and right volume scalar as float type, Property::Map with two values ( "left" and "right" ).
104        * @SINCE_1_1.38
105        */
106       VOLUME,
107
108      /**
109        * @brief name "underlay", Video rendering by underlay, true or false
110        * This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view
111        * @SINCE_1_2.62
112        * @REMARK_RAWVIDEO
113        */
114       UNDERLAY,
115
116      /**
117        * @brief The play position (millisecond) of the video.
118        * @details Name "playPosition", type Property::INTEGER
119        * @SINCE_1_3_9
120        */
121       PLAY_POSITION
122     };
123   };
124
125 public:
126
127   /**
128    * @brief Creates an initialized VideoView.
129    * @SINCE_1_1.38
130    * @return A handle to a newly allocated Dali ImageView
131    *
132    */
133   static VideoView New();
134
135   /**
136    * @brief Creates an initialized VideoView.
137    * If the string is empty, VideoView will not display anything.
138    *
139    * @SINCE_1_1.38
140    * @REMARK_INTERNET
141    * @REMARK_STORAGE
142    * @param[in] url The url of the video resource to display
143    * @return A handle to a newly allocated Dali VideoView
144    */
145   static VideoView New( const std::string& url );
146
147   /**
148    * @brief Creates an initialized VideoView.
149    * @SINCE_1_3_9
150    * @param[in] swCodec Video rendering by H/W codec if false
151    * @return A handle to a newly allocated Dali ImageView
152    *
153    * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type
154    */
155   static VideoView New( bool swCodec );
156
157   /**
158    * @brief Creates an initialized VideoView.
159    * If the string is empty, VideoView will not display anything.
160    *
161    * @SINCE_1_3_9
162    * @REMARK_INTERNET
163    * @REMARK_STORAGE
164    * @param[in] url The url of the video resource to display
165    * @param[in] swCodec Video rendering by H/W codec if false
166    * @return A handle to a newly allocated Dali VideoView
167    *
168    * @note If platform or target does not support sw codec, video-view shows an error message and video by default codec type
169    */
170   static VideoView New( const std::string& url, bool swCodec );
171
172   /**
173    * @brief Creates an uninitialized VideoView.
174    * @SINCE_1_1.38
175    */
176   VideoView();
177
178   /**
179    * @brief Destructor.
180    *
181    * This is non-virtual since derived Handel types must not contain data or virtual methods.
182    * @SINCE_1_1.38
183    */
184   ~VideoView();
185
186   /**
187    * @brief Copy constructor.
188    *
189    * @SINCE_1_1.38
190    * @param[in] videoView VideoView to copy. The copied VideoView will point at the same implementation
191    */
192   VideoView( const VideoView& videoView );
193
194   /**
195    * @brief Assignment operator.
196    *
197    * @SINCE_1_1.38
198    * @param[in] videoView The VideoView to assign from
199    * @return The updated VideoView
200    */
201   VideoView& operator=( const VideoView& videoView );
202
203   /**
204    * @brief Downcasts a handle to VideoView handle.
205    *
206    * If handle points to a VideoView, the downcast produces valid handle.
207    * If not, the returned handle is left uninitialized.
208    *
209    * @SINCE_1_1.38
210    * @param[in] handle Handle to an object
211    * @return Handle to a VideoView or an uninitialized handle
212    */
213   static VideoView DownCast( BaseHandle handle );
214
215   /**
216    * @brief Starts the video playback.
217    * @SINCE_1_1.38
218    */
219   void Play();
220
221   /**
222    * @brief Pauses the video playback.
223    * @SINCE_1_1.38
224    */
225   void Pause();
226
227   /**
228    * @brief Stops the video playback.
229    * @SINCE_1_1.38
230    */
231   void Stop();
232
233   /**
234    * @brief Seeks forward by the specified number of milliseconds.
235    *
236    * @SINCE_1_1.38
237    * @param[in] millisecond The position for forward playback
238    */
239   void Forward( int millisecond );
240
241   /**
242    * @brief Seeks backward by the specified number of milliseconds.
243    *
244    * @SINCE_1_1.38
245    * @param[in] millisecond The position for backward playback
246    */
247   void Backward( int millisecond );
248
249   /**
250    * @brief Connects to this signal to be notified when a video playback is finished.
251    *
252    * @SINCE_1_1.38
253    * @return A signal object to connect with
254    */
255   VideoViewSignalType& FinishedSignal();
256
257 public: // Not intended for application developers
258
259   /// @cond internal
260   /**
261    * @brief Creates a handle using the Toolkit::Internal implementation.
262    *
263    * @SINCE_1_1.38
264    * @param[in] implementation The VideoView implementation
265    */
266   DALI_INTERNAL VideoView( Internal::VideoView& implementation );
267
268   /**
269    * @brief Allows the creation of this VideoView from an Internal::CustomActor pointer.
270    *
271    * @SINCE_1_1.38
272    * @param[in] internal A pointer to the internal CustomActor
273    */
274   DALI_INTERNAL VideoView( Dali::Internal::CustomActor* internal );
275   /// @endcond
276
277 };
278
279 /**
280  * @}
281  */
282
283 } // namespace Toolkit
284
285 } // namespace Dali
286
287 #endif // __DALI_TOOLKIT_VIDEO_VIEW_H__