2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/devel-api/adaptor-framework/video-player.h>
19 #include <dali/devel-api/adaptor-framework/video-sync-mode.h>
20 #include <dali/public-api/object/any.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <toolkit-application.h>
33 class VideoPlayer: public Dali::BaseObject
45 mDisplyMode( Dali::VideoPlayerPlugin::DisplayMode::DST_ROI )
49 void SetMuted( bool muted )
59 void SetLooping( bool looping )
71 if( !mFinishedSignal.Empty() )
73 mFinishedSignal.Emit();
82 void SetPlayPosition( int pos )
87 Dali::VideoPlayerPlugin::DisplayMode::Type GetDisplayMode() const
92 void SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
102 void StartSynchronization()
107 void FinishSynchronization()
117 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
124 Dali::VideoPlayerPlugin::DisplayMode::Type mDisplyMode;
127 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
129 DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
130 BaseObject& handle = player.GetBaseObject();
131 return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
134 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
136 DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
137 const BaseObject& handle = player.GetBaseObject();
138 return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
141 } // namespace Adaptor
143 } // namespace Internal
146 /********************************************************************************/
147 /********************************* PUBLIC CLASS *******************************/
148 /********************************************************************************/
150 VideoPlayer::VideoPlayer()
154 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
155 : BaseHandle( internal )
159 VideoPlayer::~VideoPlayer()
163 VideoPlayer VideoPlayer::New()
165 Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
167 return VideoPlayer( player );
170 VideoPlayer VideoPlayer::New( Dali::Actor actor, Dali::VideoSyncMode syncMode )
172 Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
174 return VideoPlayer( player );
177 VideoPlayer::VideoPlayer( const VideoPlayer& player )
178 : BaseHandle( player )
182 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
184 BaseHandle::operator=( player );
188 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
190 VideoPlayer videoPlayer;
194 void VideoPlayer::SetUrl( const std::string& url )
196 Internal::Adaptor::GetImplementation( *this ).mUrl = url;
199 std::string VideoPlayer::GetUrl()
201 return Internal::Adaptor::GetImplementation( *this ).mUrl;
204 void VideoPlayer::SetLooping(bool looping)
206 Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
209 bool VideoPlayer::IsLooping()
211 return Internal::Adaptor::GetImplementation( *this ).IsLooping();
214 void VideoPlayer::Play()
218 void VideoPlayer::Pause()
222 void VideoPlayer::Stop()
224 Internal::Adaptor::GetImplementation( *this ).Stop();
227 void VideoPlayer::SetMute( bool mute )
229 Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
232 bool VideoPlayer::IsMuted()
234 return Internal::Adaptor::GetImplementation( *this ).IsMuted();
237 void VideoPlayer::SetVolume( float left, float right )
239 Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
240 Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
243 void VideoPlayer::GetVolume( float& left, float& right )
245 left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
246 right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
249 void VideoPlayer::SetRenderingTarget( Any target )
253 void VideoPlayer::SetPlayPosition( int millisecond )
255 Internal::Adaptor::GetImplementation( *this ).SetPlayPosition( millisecond );
258 int VideoPlayer::GetPlayPosition()
260 return Internal::Adaptor::GetImplementation( *this ).GetPlayPosition();
263 void VideoPlayer::SetDisplayArea( DisplayArea area )
267 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
271 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
273 return Dali::VideoPlayerPlugin::ROTATION_NONE;
276 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
278 return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
281 void VideoPlayer::Forward( int millisecond )
285 void VideoPlayer::Backward( int millisecond )
289 bool VideoPlayer::IsVideoTextureSupported()
291 return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
294 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
298 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
300 return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
303 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
305 Internal::Adaptor::GetImplementation( *this ).SetDisplayMode( mode );
308 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
310 return Internal::Adaptor::GetImplementation( *this ).GetDisplayMode();
313 Any VideoPlayer::GetMediaPlayer()
315 return Internal::Adaptor::GetImplementation( *this ).GetMediaPlayer();
318 void VideoPlayer::StartSynchronization()
320 Internal::Adaptor::GetImplementation( *this ).StartSynchronization();
323 void VideoPlayer::FinishSynchronization()
325 Internal::Adaptor::GetImplementation( *this ).FinishSynchronization();