X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fvideo-view%2Fvideo-view-example.cpp;h=d9004560cc24f089f2df816f46544abef0da3d06;hb=6982eca1b10283747278f42f4e048e914cd8a491;hp=c20b8f819ecf1619851f2040f291b93d4146eb16;hpb=e43bfb7fabc22041182ae21eb6905d4a246f002a;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/video-view/video-view-example.cpp b/examples/video-view/video-view-example.cpp index c20b8f8..d900456 100644 --- a/examples/video-view/video-view-example.cpp +++ b/examples/video-view/video-view-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,7 @@ namespace const char* const PLAY_FILE = DEMO_VIDEO_DIR "demoVideo.mp4"; const char* const PLAY_IMAGE = DEMO_IMAGE_DIR "icon-play.png"; const char* const PAUSE_IMAGE = DEMO_IMAGE_DIR "Pause.png"; - const char* const STOP_IMAGE = DEMO_IMAGE_DIR "icon-stop.png"; - const char* const RESET_IMAGE = DEMO_IMAGE_DIR "icon-reset.png"; + const char* const CHANGE_IMAGE = DEMO_IMAGE_DIR "icon-change.png"; const char* const FORWARD_IMAGE = DEMO_IMAGE_DIR "Forward.png"; const char* const BACKWARD_IMAGE = DEMO_IMAGE_DIR "Backward.png"; @@ -45,9 +44,9 @@ class VideoViewController: public ConnectionTracker VideoViewController( Application& application ) : mApplication( application ), mIsPlay( false ), - mIsStop( false ), mIsFullScreen( false ), - mScale( 1.f ) + mScale( 1.f ), + mPinchStartScale( 1.0f ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &VideoViewController::Create ); @@ -60,6 +59,8 @@ class VideoViewController: public ConnectionTracker void Create( Application& application ) { + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + mStageSize = Stage::GetCurrent().GetSize(); mVideoView = Toolkit::VideoView::New(); @@ -97,23 +98,14 @@ class VideoViewController: public ConnectionTracker mPauseButton.SetPosition( 40, 10 ); mPauseButton.ClickedSignal().Connect( this, &VideoViewController::OnButtonClicked ); - mStopButton = PushButton::New(); - mStopButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mStopButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mStopButton.SetName( "Stop" ); - mStopButton.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); - mStopButton.SetSize( BUTTON_SIZE, BUTTON_SIZE ); - mStopButton.SetPosition( 140, 10 ); - mStopButton.ClickedSignal().Connect( this, &VideoViewController::OnButtonClicked ); - - mResetButton = PushButton::New(); - mResetButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mResetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mResetButton.SetName( "Reset" ); - mResetButton.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); - mResetButton.SetSize( BUTTON_SIZE, BUTTON_SIZE ); - mResetButton.SetPosition( 140, 10 ); - mResetButton.ClickedSignal().Connect( this, &VideoViewController::OnButtonClicked ); + mChangeButton = PushButton::New(); + mChangeButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mChangeButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mChangeButton.SetName( "Change" ); + mChangeButton.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + mChangeButton.SetSize( BUTTON_SIZE, BUTTON_SIZE ); + mChangeButton.SetPosition( 140, 10 ); + mChangeButton.ClickedSignal().Connect( this, &VideoViewController::OnButtonClicked ); mBackwardButton = PushButton::New(); mBackwardButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); @@ -135,34 +127,29 @@ class VideoViewController: public ConnectionTracker mMenu.Add( mPlayButton ); mMenu.Add( mPauseButton ); - mMenu.Add( mStopButton ); - mMenu.Add( mResetButton ); + mMenu.Add( mChangeButton ); mMenu.Add( mBackwardButton ); mMenu.Add( mForwardButton ); mPauseButton.SetVisible( false ); - mPauseButton.SetDisabled( true ); + mPauseButton.SetProperty( Button::Property::DISABLED, true ); mPlayButton.SetVisible( true ); - mPlayButton.SetDisabled( false ); - mStopButton.SetVisible( true ); - mStopButton.SetDisabled( false ); - mResetButton.SetVisible( false ); - mResetButton.SetDisabled( true ); - - mPlayButton.SetUnselectedImage( PLAY_IMAGE ); - mPlayButton.SetSelectedImage( PLAY_IMAGE ); - mPauseButton.SetUnselectedImage( PAUSE_IMAGE ); - mPauseButton.SetSelectedImage( PAUSE_IMAGE ); - - mStopButton.SetUnselectedImage( STOP_IMAGE ); - mStopButton.SetSelectedImage( STOP_IMAGE ); - mResetButton.SetUnselectedImage( RESET_IMAGE ); - mResetButton.SetSelectedImage( RESET_IMAGE ); - - mBackwardButton.SetUnselectedImage( BACKWARD_IMAGE ); - mBackwardButton.SetSelectedImage( BACKWARD_IMAGE ); - mForwardButton.SetUnselectedImage( FORWARD_IMAGE ); - mForwardButton.SetSelectedImage( FORWARD_IMAGE ); + mPlayButton.SetProperty( Button::Property::DISABLED, false ); + mChangeButton.SetVisible( true ); + mChangeButton.SetProperty( Button::Property::DISABLED, false ); + + mPlayButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, PLAY_IMAGE ); + mPlayButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, PLAY_IMAGE ); + mPauseButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, PAUSE_IMAGE ); + mPauseButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, PAUSE_IMAGE ); + + mChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_IMAGE ); + mChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_IMAGE ); + + mBackwardButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, BACKWARD_IMAGE ); + mBackwardButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, BACKWARD_IMAGE ); + mForwardButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, FORWARD_IMAGE ); + mForwardButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, FORWARD_IMAGE ); mPanGestureDetector = PanGestureDetector::New(); mPanGestureDetector.Attach( mVideoView ); @@ -182,23 +169,18 @@ class VideoViewController: public ConnectionTracker Stage::GetCurrent().KeyEventSignal().Connect( this, &VideoViewController::OnKeyEvent ); - mWindowSurfaceTarget.Insert( "RENDERING_TARGET", "windowSurfaceTarget" ); - mNativeImageTarget.Insert( "RENDERING_TARGET", "nativeImageTarget" ); - - mVideoView.FinishedSignal().Connect( this, &VideoViewController::OnFinished ); } bool OnButtonClicked( Button button ) { - if( mPauseButton.GetId() == button.GetId()) { if( mIsPlay ) { mPauseButton.SetVisible( false ); - mPauseButton.SetDisabled( true ); + mPauseButton.SetProperty( Button::Property::DISABLED, true ); mPlayButton.SetVisible( true ); - mPlayButton.SetDisabled( false ); + mPlayButton.SetProperty( Button::Property::DISABLED, false ); mIsPlay = false; mVideoView.Pause(); @@ -206,51 +188,26 @@ class VideoViewController: public ConnectionTracker } else if( mPlayButton.GetId() == button.GetId()) { - if( mIsStop ) - { - return false; - } - mPauseButton.SetVisible( true ); - mPauseButton.SetDisabled( false ); + mPauseButton.SetProperty( Button::Property::DISABLED, false ); mPlayButton.SetVisible( false ); - mPlayButton.SetDisabled( true ); + mPlayButton.SetProperty( Button::Property::DISABLED, true ); mIsPlay = true; mVideoView.Play(); } - else if( mResetButton.GetId() == button.GetId()) + else if( mChangeButton.GetId() == button.GetId()) { - if( mIsStop ) + bool underlay = false; + underlay = mVideoView.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + if( underlay ) { - mPauseButton.SetVisible( true ); - mPauseButton.SetDisabled( false ); - mPlayButton.SetVisible( false ); - mPlayButton.SetDisabled( true ); - mResetButton.SetVisible( false ); - mResetButton.SetDisabled( true ); - mStopButton.SetVisible( true ); - mStopButton.SetDisabled( false ); - - mIsStop = false; - mIsPlay = true; - mVideoView.SetProperty( VideoView::Property::VIDEO, PLAY_FILE ); - mVideoView.Play(); + mVideoView.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false ); + } + else + { + mVideoView.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true ); } - } - else if( mStopButton.GetId() == button.GetId()) - { - mPauseButton.SetVisible( false ); - mPauseButton.SetDisabled( true ); - mPlayButton.SetVisible( true ); - mPlayButton.SetDisabled( false ); - mResetButton.SetVisible( true ); - mResetButton.SetDisabled( false ); - mStopButton.SetVisible( false ); - mStopButton.SetDisabled( true ); - - mIsStop = true; - mVideoView.Stop(); } else if( mBackwardButton.GetId() == button.GetId()) { @@ -264,15 +221,6 @@ class VideoViewController: public ConnectionTracker return true; } - void OnFinished( VideoView& view ) - { - if( !mIsFullScreen ) - { - mRotationAnimation.Play(); - mIsStop = true; - } - } - void OnPan( Actor actor, const PanGesture& gesture ) { if( !mIsFullScreen && gesture.state == Gesture::Continuing ) @@ -291,20 +239,7 @@ class VideoViewController: public ConnectionTracker if( gesture.state == Gesture::Finished ) { mScale = mPinchStartScale * gesture.scale; - if( mScale > 1.f ) - { - mVideoView.SetSize( mStageSize.x, mStageSize.y ); - mVideoView.SetProperty( VideoView::Property::VIDEO, mWindowSurfaceTarget ); - mMenu.SetSize( mStageSize.x, 120 ); - mIsFullScreen = true; - } - else - { - mVideoView.SetSize( INIT_WIDTH, INIT_HEIGHT ); - mVideoView.SetProperty( VideoView::Property::VIDEO, mNativeImageTarget ); - mMenu.SetSize( INIT_WIDTH, 120 ); - mIsFullScreen = false; - } + mVideoView.SetScale( mScale ); } } @@ -312,7 +247,13 @@ class VideoViewController: public ConnectionTracker { if( !mIsFullScreen ) { - mRotationAnimation.Play(); + mVideoView.SetSize( mStageSize.x, mStageSize.y ); + mIsFullScreen = true; + } + else + { + mVideoView.SetSize( INIT_WIDTH, INIT_HEIGHT ); + mIsFullScreen = false; } } @@ -339,12 +280,11 @@ private: Vector2 mStageSize; bool mIsPlay; - bool mIsStop; bool mIsFullScreen; PushButton mPlayButton; PushButton mPauseButton; - PushButton mStopButton; + PushButton mChangeButton; PushButton mResetButton; PushButton mBackwardButton; PushButton mForwardButton; @@ -356,24 +296,12 @@ private: float mPinchStartScale; Animation mRotationAnimation; - Property::Map mWindowSurfaceTarget; - Property::Map mNativeImageTarget; }; -void RunTest( Application& application ) -{ - VideoViewController test( application ); - - application.MainLoop(); -} - -// Entry point for Linux & Tizen applications -// int DALI_EXPORT_API main( int argc, char **argv ) { Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); - - RunTest( application ); - + VideoViewController test( application ); + application.MainLoop(); return 0; }