X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fvideo-view%2Fvideo-view-impl.cpp;h=587663300aa3efce8fe9b037847e5cadc5a563e3;hb=ee0a1565d8a52fafc20e2c5beab39db93dcd427b;hp=58349507c9e25770c3fd5010662deaef5e35bff1;hpb=26080f936f851754221bb16e4e5e3834c24b96db;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index 5834950..5876633 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -63,6 +63,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY ) +DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "playPosition", INTEGER, PLAY_POSITION ) DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL ) @@ -106,48 +107,19 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( }\n ); -struct TriggerFunctor -{ - TriggerFunctor( TriggerEventInterface* notification ) - : mNotification( notification ) - { - } - - void operator()( bool& current, const PropertyInputContainer& inputs ) - { - if( mNotification != NULL ) - { - mNotification->Trigger(); - } - } - - TriggerEventInterface* mNotification; -}; - } // anonymous namepsace VideoView::VideoView() : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ), - mUpdateTriggerPropertyIndex( Property::INVALID_INDEX), - mNotification( NULL ), mCurrentVideoPlayPosition( 0 ), mIsPlay( false ), - mIsPause( false ), mIsUnderlay( true ) { mVideoPlayer = Dali::VideoPlayer::New(); - - TriggerEventFactory triggerEventFactory; - mNotification = triggerEventFactory.CreateTriggerEvent( MakeCallback(this, &VideoView::UpdateDisplayArea ), - TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER); } VideoView::~VideoView() { - if( mNotification != NULL ) - { - delete mNotification; - } } Toolkit::VideoView VideoView::New() @@ -162,7 +134,6 @@ Toolkit::VideoView VideoView::New() void VideoView::OnInitialize() { - mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true ); mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); SetWindowSurfaceTarget(); } @@ -245,23 +216,25 @@ bool VideoView::IsLooping() void VideoView::Play() { + if( mIsUnderlay ) + { + Self().AddRenderer( mRenderer ); + } + mVideoPlayer.Play(); mIsPlay = true; - mIsPause = false; } void VideoView::Pause() { mVideoPlayer.Pause(); mIsPlay = false; - mIsPause = true; } void VideoView::Stop() { mVideoPlayer.Stop(); mIsPlay = false; - mIsPause = false; } void VideoView::Forward( int millisecond ) @@ -310,6 +283,11 @@ Dali::Toolkit::VideoView::VideoViewSignalType& VideoView::FinishedSignal() void VideoView::EmitSignalFinish() { + if( mIsUnderlay ) + { + Self().RemoveRenderer( mRenderer ); + } + if ( !mFinishedSignal.Empty() ) { Dali::Toolkit::VideoView handle( GetOwner() ); @@ -474,6 +452,15 @@ void VideoView::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::VideoView::Property::PLAY_POSITION: + { + int pos; + if( value.Get( pos ) ) + { + impl.SetPlayPosition( pos ); + } + break; + } } } } @@ -527,6 +514,11 @@ Property::Value VideoView::GetProperty( BaseObject* object, Property::Index prop value = impl.IsUnderlay(); break; } + case Toolkit::VideoView::Property::PLAY_POSITION: + { + value = impl.GetPlayPosition(); + break; + } } } @@ -615,10 +607,17 @@ void VideoView::SetWindowSurfaceTarget() mVisual.Reset(); } - Constraint constraint = Constraint::New( self, mUpdateTriggerPropertyIndex, TriggerFunctor( mNotification ) ); - constraint.AddSource( Source( self, Actor::Property::POSITION ) ); - constraint.AddSource( Source( self, Actor::Property::SIZE ) ); - constraint.Apply(); + if( mIsPlay ) + { + mVideoPlayer.Pause(); + } + + mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) ); + mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) ); + mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) ); + mPositionUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea ); + mSizeUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea ); + mScaleUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea ); mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); mVideoPlayer.SetUrl( mUrl ); @@ -636,18 +635,10 @@ void VideoView::SetWindowSurfaceTarget() mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE ); mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO ); } - self.AddRenderer( mRenderer ); - - UpdateDisplayArea(); if( mIsPlay ) { - mVideoPlayer.Play(); - } - if( mIsPause ) - { - mVideoPlayer.Play(); - mVideoPlayer.Pause(); + Play(); } if( curPos > 0 ) @@ -665,7 +656,19 @@ void VideoView::SetNativeImageTarget() return; } + if( mIsPlay ) + { + mVideoPlayer.Pause(); + } + Actor self( Self() ); + self.RemoveRenderer( mRenderer ); + Dali::Stage::GetCurrent().KeepRendering( 0.0f ); + + self.RemovePropertyNotification( mPositionUpdateNotification ); + self.RemovePropertyNotification( mSizeUpdateNotification ); + self.RemovePropertyNotification( mScaleUpdateNotification ); + int curPos = mVideoPlayer.GetPlayPosition(); Any source; @@ -680,21 +683,16 @@ void VideoView::SetNativeImageTarget() if( mIsPlay ) { - mVideoPlayer.Play(); + Play(); } - if( mIsPause ) - { - mVideoPlayer.Play(); - mVideoPlayer.Pause(); - } if( curPos > 0 ) { mVideoPlayer.SetPlayPosition( curPos ); } } -void VideoView::UpdateDisplayArea() +void VideoView::UpdateDisplayArea( Dali::PropertyNotification& source ) { if( !mIsUnderlay ) { @@ -731,6 +729,8 @@ void VideoView::SetUnderlay( bool set ) { SetNativeImageTarget(); } + + RelayoutRequest(); } } @@ -739,6 +739,30 @@ bool VideoView::IsUnderlay() return mIsUnderlay; } +void VideoView::SetSWCodec( bool on ) +{ + // If setting SW or HW type is failed , video-view shows video by default codec type. + // The default codec type is selected by platform. + if( on ) + { + mVideoPlayer.SetCodecType( Dali::VideoPlayerPlugin::CodecType::SW ); + } + else + { + mVideoPlayer.SetCodecType( Dali::VideoPlayerPlugin::CodecType::HW ); + } +} + +int VideoView::GetPlayPosition() +{ + return mVideoPlayer.GetPlayPosition(); +} + +void VideoView::SetPlayPosition( int pos ) +{ + mVideoPlayer.SetPlayPosition( pos ); +} + } // namespace Internal } // namespace toolkit