/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
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_PROPERTY_REGISTRATION( Toolkit, VideoView, "displayMode", INTEGER, DISPLAY_MODE )
DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL )
const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
uniform lowp vec4 uColor;\n
uniform lowp vec3 mixColor;\n
- uniform lowp float opacity;\n
\n
void main()\n
{\n
- gl_FragColor = vec4(mixColor, opacity)*uColor;\n
+ gl_FragColor = vec4(mixColor, 1.0)*uColor;\n
}\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()
void VideoView::OnInitialize()
{
- mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true );
mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
SetWindowSurfaceTarget();
}
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 )
void VideoView::EmitSignalFinish()
{
+ if( mIsUnderlay )
+ {
+ Self().RemoveRenderer( mRenderer );
+ }
+
if ( !mFinishedSignal.Empty() )
{
Dali::Toolkit::VideoView handle( GetOwner() );
}
break;
}
+ case Toolkit::VideoView::Property::PLAY_POSITION:
+ {
+ int pos;
+ if( value.Get( pos ) )
+ {
+ impl.SetPlayPosition( pos );
+ }
+ break;
+ }
+ case Toolkit::VideoView::Property::DISPLAY_MODE:
+ {
+ int mode;
+ if( value.Get( mode ) )
+ {
+ impl.SetDisplayMode( mode );
+ }
+ break;
+ }
}
}
}
value = impl.IsUnderlay();
break;
}
+ case Toolkit::VideoView::Property::PLAY_POSITION:
+ {
+ value = impl.GetPlayPosition();
+ break;
+ }
+ case Toolkit::VideoView::Property::DISPLAY_MODE:
+ {
+ value = impl.GetDisplayMode();
+ break;
+ }
}
}
mVisual.Reset();
}
- Constraint constraint = Constraint::New<bool>( 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 );
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 )
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;
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 )
{
{
SetNativeImageTarget();
}
+
+ RelayoutRequest();
}
}
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 );
+}
+
+void VideoView::SetDisplayMode( int mode )
+{
+ mVideoPlayer.SetDisplayMode( static_cast< Dali::VideoPlayerPlugin::DisplayMode::Type >( mode ) );
+}
+
+int VideoView::GetDisplayMode() const
+{
+ return static_cast< int >( mVideoPlayer.GetDisplayMode() );
+}
+
} // namespace Internal
} // namespace toolkit