1 #ifndef DALI_VIDEO_PLAYER_H
2 #define DALI_VIDEO_PLAYER_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
23 #include <dali/public-api/object/base-handle.h>
26 #include <dali/devel-api/adaptor-framework/video-player-plugin.h>
27 #include <dali/public-api/dali-adaptor-common.h>
38 } // namespace Adaptor
40 } // namespace Internal
43 * @brief VideoPlayer class is used for video playback.
46 class DALI_ADAPTOR_API VideoPlayer : public BaseHandle
62 * @brief Creates a new instance of a VideoPlayer.
65 static VideoPlayer New();
68 * @brief Creates a new instance of a VideoPlayer.
70 * If you want the video player works with Ui synchronous when video player is resized/moved,
71 * put the video view actor and the enabled syncMode.
73 * @param[in] actor video view's actor instance
74 * @param[in] syncMode The synchronization mode between the UI (transparent hole) and VideoPlayer.
76 static VideoPlayer New(Dali::Actor actor, VideoSyncMode syncMode);
79 * @brief Copy constructor.
82 * @param[in] player VideoPlayer to copy. The copied player will point at the same implementation
84 VideoPlayer(const VideoPlayer& player);
87 * @brief Assignment operator.
90 * @param[in] player The VideoPlayer to assign from.
91 * @return The updated VideoPlayer.
93 VideoPlayer& operator=(const VideoPlayer& player);
96 * @brief Move constructor.
99 * @param[in] player VideoPlayer to move. The moved player will point at the same implementation
101 VideoPlayer(VideoPlayer&& player);
104 * @brief Move assignment operator.
107 * @param[in] player The VideoPlayer to move assign from.
108 * @return The updated VideoPlayer.
110 VideoPlayer& operator=(VideoPlayer&& player);
113 * @brief Downcast a handle to VideoPlayer handle.
115 * If handle points to a VideoPlayer the downcast produces valid
116 * handle. If not the returned handle is left uninitialized.
119 * @param[in] handle Handle to an object
120 * @return Handle to a VideoPlayer or an uninitialized handle
122 static VideoPlayer DownCast(BaseHandle handle);
125 * @brief Sets a URL of the video file to play.
128 * @param [in] url The url of video file
130 void SetUrl(const std::string& url);
133 * @brief Returns the URL of the video file.
135 * @return Url of string type
137 std::string GetUrl();
140 * @brief Sets the player looping status.
143 * @param [in] looping The new looping status: true or false
145 void SetLooping(bool looping);
148 * @brief Returns the player looping status.
151 * @return True if player is looping, false otherwise.
156 * @brief Starts the video playback.
162 * @brief Pauses the video playback.
168 * @brief Stops the video playback.
174 * @brief Sets the player mute status.
176 * @param[in] mute The new mute status, true is mute.
178 void SetMute(bool mute);
181 * @brief Returns the player mute status.
183 * @return True if player is mute.
188 * @brief Sets the player volume.
190 * @param[in] left The left volume scalar
191 * @param[in] right The right volume scalar
193 void SetVolume(float left, float right);
196 * @brief Returns current volume factor.
198 * @param[out] left The current left volume scalar
199 * @param[out] right The current right volume scalar
201 void GetVolume(float& left, float& right);
204 * @brief Sets video rendering target.
206 * @param[in] target The target for video rendering, window surface or native image source
208 void SetRenderingTarget(Any target);
211 * @brief Sets the position for playback.
214 * @param[in] millisecond The position for playback
216 void SetPlayPosition(int millisecond);
219 * @brief Gets the current position in milliseconds.
222 * @return The current position of playback
224 int GetPlayPosition();
227 * @brief Sets the area of video display.
229 * param[in] area The left-top position and size of the video display area
231 void SetDisplayArea(DisplayArea area);
234 * @brief Sets video display rotation
236 * @param[in] rotation The rotation of display
238 void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
241 * @brief Returns rotation of current video display
243 * @return The rotation of current display
245 Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
248 * @brief Connect to this signal to be notified when a video playback have finished.
251 * @return A signal object to connect with.
253 Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
256 * @brief Seeks forward by the specified number of milliseconds.
259 * @param[in] millisecond The position for forward playback
261 void Forward(int millisecond);
264 * @brief Seeks backward by the specified number of milliseconds.
267 * @param[in] millisecond The position for backward playback
269 void Backward(int millisecond);
272 * @brief Checks whether the video texture is supported
273 * @return True if supported, otherwise false.
275 bool IsVideoTextureSupported();
278 * @brief Sets codec type
279 * @param[in] type The VideoCodec::Type
281 void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
284 * @brief Gets codec type
285 * @return VideoCodec::Type
287 Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
290 * @brief Sets the display mode for playback.
291 * @param[in] mode of playback
293 void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
296 * @brief Gets display mode
297 * @return DisplayMode
299 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
302 * @brief Gets the media player of video player
303 * @return player The media player
305 Any GetMediaPlayer();
308 * @brief calls synchronization function in window system
309 * This function is called, the synchronization is started between UI(transparent hole) and video player.
311 void StartSynchronization();
314 * @brief calls desynchronization function in window system
315 * This function is called, the synchronization is ended between UI(transparent hole) and video player.
317 void FinishSynchronization();
320 * @brief Raise the video player above the target video plaer.
322 * @param[in] target The target video player
324 void RaiseAbove(Dali::VideoPlayer target);
327 * @brief Lower the video player to below the target video player.
329 * @param[in] target The target video player
331 void LowerBelow(Dali::VideoPlayer target);
334 * @brief Raise video player above all other sibling video players.
339 * @brief Lower video player to the bottom of all other sibling video players.
341 void LowerToBottom();
343 private: // Not intended for application developers
345 * @brief Internal constructor
348 explicit DALI_INTERNAL VideoPlayer(Internal::Adaptor::VideoPlayer* internal);
353 #endif // DALI_VIDEO_PLAYER_H