void VideoView::OnInitialize()
{
mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
- SetWindowSurfaceTarget();
}
void VideoView::SetUrl( const std::string& url )
void VideoView::Play()
{
- if( mIsUnderlay )
+ if( mOverlayRenderer )
{
Self().AddRenderer( mOverlayRenderer );
}
void VideoView::EmitSignalFinish()
{
- if( mIsUnderlay )
+ if( mOverlayRenderer )
{
Self().RemoveRenderer( mOverlayRenderer );
}
return connected;
}
-void VideoView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+void VideoView::SetPropertyInternal( Property::Index index, const Property::Value& value )
{
- Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( Dali::BaseHandle( object ) );
-
- if( videoView )
+ switch( index )
{
- VideoView& impl = GetImpl( videoView );
-
- switch( index )
+ case Toolkit::VideoView::Property::VIDEO:
{
- case Toolkit::VideoView::Property::VIDEO:
- {
- std::string videoUrl;
- Property::Map map;
+ std::string videoUrl;
+ Property::Map map;
- if( value.Get( videoUrl ) )
- {
- impl.SetUrl( videoUrl );
- }
- else if( value.Get( map ) )
- {
- impl.SetPropertyMap( map );
- }
- break;
+ if( value.Get( videoUrl ) )
+ {
+ SetUrl( videoUrl );
}
- case Toolkit::VideoView::Property::LOOPING:
+ else if( value.Get( map ) )
{
- bool looping;
- if( value.Get( looping ) )
- {
- impl.SetLooping( looping );
- }
- break;
+ SetPropertyMap( map );
}
- case Toolkit::VideoView::Property::MUTED:
+ break;
+ }
+ case Toolkit::VideoView::Property::LOOPING:
+ {
+ bool looping;
+ if( value.Get( looping ) )
{
- bool mute;
- if( value.Get( mute ) )
- {
- impl.SetMute( mute );
- }
- break;
+ SetLooping( looping );
}
- case Toolkit::VideoView::Property::VOLUME:
+ break;
+ }
+ case Toolkit::VideoView::Property::MUTED:
+ {
+ bool mute;
+ if( value.Get( mute ) )
{
- Property::Map map;
- float left, right;
- if( value.Get( map ) )
- {
- Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
- Property::Value* volumeRight = map.Find( VOLUME_RIGHT );
- if( volumeLeft && volumeLeft->Get( left ) && volumeRight && volumeRight->Get( right ) )
- {
- impl.SetVolume( left, right );
- }
- }
- break;
+ SetMute( mute );
}
- case Toolkit::VideoView::Property::UNDERLAY:
+ break;
+ }
+ case Toolkit::VideoView::Property::VOLUME:
+ {
+ Property::Map map;
+ float left, right;
+ if( value.Get( map ) )
{
- bool underlay;
- if( value.Get( underlay ) )
+ Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
+ Property::Value* volumeRight = map.Find( VOLUME_RIGHT );
+ if( volumeLeft && volumeLeft->Get( left ) && volumeRight && volumeRight->Get( right ) )
{
- impl.SetUnderlay( underlay );
+ SetVolume( left, right );
}
- break;
}
- case Toolkit::VideoView::Property::PLAY_POSITION:
+ break;
+ }
+ case Toolkit::VideoView::Property::UNDERLAY:
+ {
+ bool underlay;
+ if( value.Get( underlay ) )
{
- int pos;
- if( value.Get( pos ) )
- {
- impl.SetPlayPosition( pos );
- }
- break;
+ SetUnderlay( underlay );
}
- case Toolkit::VideoView::Property::DISPLAY_MODE:
+ break;
+ }
+ case Toolkit::VideoView::Property::PLAY_POSITION:
+ {
+ int pos;
+ if( value.Get( pos ) )
{
- int mode;
- if( value.Get( mode ) )
- {
- impl.SetDisplayMode( mode );
- }
- break;
+ SetPlayPosition( pos );
}
+ break;
+ }
+ case Toolkit::VideoView::Property::DISPLAY_MODE:
+ {
+ int mode;
+ if( value.Get( mode ) )
+ {
+ SetDisplayMode( mode );
+ }
+ break;
+ }
+ }
+}
+
+void VideoView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::VideoView videoView = Toolkit::VideoView::DownCast( Dali::BaseHandle( object ) );
+
+ if( videoView )
+ {
+ VideoView& impl = GetImpl( videoView );
+
+ impl.SetPropertyInternal( index, value );
+
+ if( index != Toolkit::VideoView::Property::UNDERLAY )
+ {
+ // Backup values.
+ // These values will be used when underlay mode is changed.
+ impl.mPropertyBackup[index] = value;
}
}
}
void VideoView::OnStageConnection( int depth )
{
Control::OnStageConnection( depth );
+
+ if( mIsUnderlay )
+ {
+ SetWindowSurfaceTarget();
+ }
}
void VideoView::OnStageDisconnection()
void VideoView::SetWindowSurfaceTarget()
{
Actor self = Self();
+
+ if( !self.OnStage() )
+ {
+ // When the control is off the stage, it does not have Window.
+ return;
+ }
+
int curPos = mVideoPlayer.GetPlayPosition();
if( mIsPlay )
self.RemoveRenderer( mTextureRenderer );
}
- mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
- mVideoPlayer.SetUrl( mUrl );
+ // Note VideoPlayer::SetRenderingTarget resets all the options. (e.g. url, mute, looping)
+ mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle( self ) );
+
+ ApplyBackupProperties();
if( !mOverlayRenderer )
{
if( mOverlayRenderer )
{
self.RemoveRenderer( mOverlayRenderer );
+
+ mOverlayRenderer.Reset();
}
self.RemovePropertyNotification( mPositionUpdateNotification );
}
Self().AddRenderer( mTextureRenderer );
+ // Note VideoPlayer::SetRenderingTarget resets all the options. (e.g. url, mute, looping)
mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
- mVideoPlayer.SetUrl( mUrl );
+
+ ApplyBackupProperties();
if( mIsPlay )
{
return extracted;
}
+void VideoView::ApplyBackupProperties()
+{
+ Property::Map::SizeType pos = 0;
+ Property::Map::SizeType count = mPropertyBackup.Count();
+
+ for( ; pos < count; pos++ )
+ {
+ KeyValuePair property = mPropertyBackup.GetKeyValue( pos );
+
+ SetPropertyInternal( property.first.indexKey, property.second );
+ }
+}
+
} // namespace Internal
} // namespace toolkit