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()
112 void RaiseAbove(Dali::VideoPlayer target)
117 void LowerBelow(Dali::VideoPlayer target)
137 Dali::VideoPlayerPlugin::VideoPlayerSignalType mFinishedSignal;
144 Dali::VideoPlayerPlugin::DisplayMode::Type mDisplyMode;
147 inline VideoPlayer& GetImplementation( Dali::VideoPlayer& player )
149 DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
150 BaseObject& handle = player.GetBaseObject();
151 return static_cast< Internal::Adaptor::VideoPlayer& >( handle );
154 inline const VideoPlayer& GetImplementation( const Dali::VideoPlayer& player )
156 DALI_ASSERT_ALWAYS(player && "VideoPlayer handle is empty");
157 const BaseObject& handle = player.GetBaseObject();
158 return static_cast< const Internal::Adaptor::VideoPlayer& >( handle );
161 } // namespace Adaptor
163 } // namespace Internal
166 /********************************************************************************/
167 /********************************* PUBLIC CLASS *******************************/
168 /********************************************************************************/
170 VideoPlayer::VideoPlayer()
174 VideoPlayer::VideoPlayer( Internal::Adaptor::VideoPlayer* internal )
175 : BaseHandle( internal )
179 VideoPlayer::~VideoPlayer()
183 VideoPlayer VideoPlayer::New()
185 Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
187 return VideoPlayer( player );
190 VideoPlayer VideoPlayer::New( Dali::Actor actor, Dali::VideoSyncMode syncMode )
192 Internal::Adaptor::VideoPlayer* player = new Internal::Adaptor::VideoPlayer();
194 return VideoPlayer( player );
197 VideoPlayer::VideoPlayer( const VideoPlayer& player )
198 : BaseHandle( player )
202 VideoPlayer& VideoPlayer::operator=( const VideoPlayer& player )
204 BaseHandle::operator=( player );
208 VideoPlayer VideoPlayer::DownCast( BaseHandle handle )
210 VideoPlayer videoPlayer;
214 void VideoPlayer::SetUrl( const std::string& url )
216 Internal::Adaptor::GetImplementation( *this ).mUrl = url;
219 std::string VideoPlayer::GetUrl()
221 return Internal::Adaptor::GetImplementation( *this ).mUrl;
224 void VideoPlayer::SetLooping(bool looping)
226 Internal::Adaptor::GetImplementation( *this ).SetLooping( looping );
229 bool VideoPlayer::IsLooping()
231 return Internal::Adaptor::GetImplementation( *this ).IsLooping();
234 void VideoPlayer::Play()
238 void VideoPlayer::Pause()
242 void VideoPlayer::Stop()
244 Internal::Adaptor::GetImplementation( *this ).Stop();
247 void VideoPlayer::SetMute( bool mute )
249 Internal::Adaptor::GetImplementation( *this ).SetMuted( mute );
252 bool VideoPlayer::IsMuted()
254 return Internal::Adaptor::GetImplementation( *this ).IsMuted();
257 void VideoPlayer::SetVolume( float left, float right )
259 Internal::Adaptor::GetImplementation( *this ).mVolumeLeft = left;
260 Internal::Adaptor::GetImplementation( *this ).mVolumeRight = right;
263 void VideoPlayer::GetVolume( float& left, float& right )
265 left = Internal::Adaptor::GetImplementation( *this ).mVolumeLeft;
266 right = Internal::Adaptor::GetImplementation( *this ).mVolumeRight;
269 void VideoPlayer::SetRenderingTarget( Any target )
273 void VideoPlayer::SetPlayPosition( int millisecond )
275 Internal::Adaptor::GetImplementation( *this ).SetPlayPosition( millisecond );
278 int VideoPlayer::GetPlayPosition()
280 return Internal::Adaptor::GetImplementation( *this ).GetPlayPosition();
283 void VideoPlayer::SetDisplayArea( DisplayArea area )
287 void VideoPlayer::SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation )
291 Dali::VideoPlayerPlugin::DisplayRotation VideoPlayer::GetDisplayRotation()
293 return Dali::VideoPlayerPlugin::ROTATION_NONE;
296 Dali::VideoPlayerPlugin::VideoPlayerSignalType& VideoPlayer::FinishedSignal()
298 return Internal::Adaptor::GetImplementation( *this ).mFinishedSignal;
301 void VideoPlayer::Forward( int millisecond )
305 void VideoPlayer::Backward( int millisecond )
309 bool VideoPlayer::IsVideoTextureSupported()
311 return ToolkitApplication::DECODED_IMAGES_SUPPORTED;
314 void VideoPlayer::SetCodecType( Dali::VideoPlayerPlugin::CodecType type )
318 Dali::VideoPlayerPlugin::CodecType VideoPlayer::GetCodecType() const
320 return Dali::VideoPlayerPlugin::CodecType::DEFAULT;
323 void VideoPlayer::SetDisplayMode( Dali::VideoPlayerPlugin::DisplayMode::Type mode )
325 Internal::Adaptor::GetImplementation( *this ).SetDisplayMode( mode );
328 Dali::VideoPlayerPlugin::DisplayMode::Type VideoPlayer::GetDisplayMode() const
330 return Internal::Adaptor::GetImplementation( *this ).GetDisplayMode();
333 Any VideoPlayer::GetMediaPlayer()
335 return Internal::Adaptor::GetImplementation( *this ).GetMediaPlayer();
338 void VideoPlayer::StartSynchronization()
340 Internal::Adaptor::GetImplementation( *this ).StartSynchronization();
343 void VideoPlayer::FinishSynchronization()
345 Internal::Adaptor::GetImplementation( *this ).FinishSynchronization();
348 void VideoPlayer::RaiseAbove(Dali::VideoPlayer target)
350 Internal::Adaptor::GetImplementation( *this ).RaiseAbove(target);
353 void VideoPlayer::LowerBelow(Dali::VideoPlayer target)
355 Internal::Adaptor::GetImplementation( *this ).LowerBelow(target);
358 void VideoPlayer::RaiseToTop()
360 Internal::Adaptor::GetImplementation( *this ).RaiseToTop();
363 void VideoPlayer::LowerToBottom()
365 Internal::Adaptor::GetImplementation( *this ).LowerToBottom();