1 #ifndef DALI_VIDEO_PLAYER_H
2 #define DALI_VIDEO_PLAYER_H
5 * Copyright (c) 2020 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 Downcast a handle to VideoPlayer handle.
98 * If handle points to a VideoPlayer the downcast produces valid
99 * handle. If not the returned handle is left uninitialized.
102 * @param[in] handle Handle to an object
103 * @return Handle to a VideoPlayer or an uninitialized handle
105 static VideoPlayer DownCast(BaseHandle handle);
108 * @brief Sets a URL of the video file to play.
111 * @param [in] url The url of video file
113 void SetUrl(const std::string& url);
116 * @brief Returns the URL of the video file.
118 * @return Url of string type
120 std::string GetUrl();
123 * @brief Sets the player looping status.
126 * @param [in] looping The new looping status: true or false
128 void SetLooping(bool looping);
131 * @brief Returns the player looping status.
134 * @return True if player is looping, false otherwise.
139 * @brief Starts the video playback.
145 * @brief Pauses the video playback.
151 * @brief Stops the video playback.
157 * @brief Sets the player mute status.
159 * @param[in] mute The new mute status, true is mute.
161 void SetMute(bool mute);
164 * @brief Returns the player mute status.
166 * @return True if player is mute.
171 * @brief Sets the player volume.
173 * @param[in] left The left volume scalar
174 * @param[in] right The right volume scalar
176 void SetVolume(float left, float right);
179 * @brief Returns current volume factor.
181 * @param[out] left The current left volume scalar
182 * @param[out] right The current right volume scalar
184 void GetVolume(float& left, float& right);
187 * @brief Sets video rendering target.
189 * @param[in] target The target for video rendering, window surface or native image source
191 void SetRenderingTarget(Any target);
194 * @brief Sets the position for playback.
197 * @param[in] millisecond The position for playback
199 void SetPlayPosition(int millisecond);
202 * @brief Gets the current position in milliseconds.
205 * @return The current position of playback
207 int GetPlayPosition();
210 * @brief Sets the area of video display.
212 * param[in] area The left-top position and size of the video display area
214 void SetDisplayArea(DisplayArea area);
217 * @brief Sets video display rotation
219 * @param[in] rotation The rotation of display
221 void SetDisplayRotation(Dali::VideoPlayerPlugin::DisplayRotation rotation);
224 * @brief Returns rotation of current video display
226 * @return The rotation of current display
228 Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation();
231 * @brief Connect to this signal to be notified when a video playback have finished.
234 * @return A signal object to connect with.
236 Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal();
239 * @brief Seeks forward by the specified number of milliseconds.
242 * @param[in] millisecond The position for forward playback
244 void Forward(int millisecond);
247 * @brief Seeks backward by the specified number of milliseconds.
250 * @param[in] millisecond The position for backward playback
252 void Backward(int millisecond);
255 * @brief Checks whether the video texture is supported
256 * @return True if supported, otherwise false.
258 bool IsVideoTextureSupported();
261 * @brief Sets codec type
262 * @param[in] type The VideoCodec::Type
264 void SetCodecType(Dali::VideoPlayerPlugin::CodecType type);
267 * @brief Gets codec type
268 * @return VideoCodec::Type
270 Dali::VideoPlayerPlugin::CodecType GetCodecType() const;
273 * @brief Sets the display mode for playback.
274 * @param[in] mode of playback
276 void SetDisplayMode(Dali::VideoPlayerPlugin::DisplayMode::Type mode);
279 * @brief Gets display mode
280 * @return DisplayMode
282 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const;
285 * @brief Gets the media player of video player
286 * @return player The media player
288 Any GetMediaPlayer();
291 * @brief calls synchronization function in window system
292 * This function is called, the synchronization is started between UI(transparent hole) and video player.
294 void StartSynchronization();
297 * @brief calls desynchronization function in window system
298 * This function is called, the synchronization is ended between UI(transparent hole) and video player.
300 void FinishSynchronization();
302 private: // Not intended for application developers
304 * @brief Internal constructor
307 explicit DALI_INTERNAL VideoPlayer(Internal::Adaptor::VideoPlayer* internal);
312 #endif // DALI_VIDEO_PLAYER_H