END_TEST;
}
+
+int UtcDaliVideoViewPropertyUnderlay(void)
+{
+ ToolkitTestApplication application;
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+ VideoView view = VideoView::New();
+ DALI_TEST_CHECK( view );
+
+ Stage::GetCurrent().Add( view );
+ view.Play();
+
+ application.SendNotification();
+ application.Render();
+
+ bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ view.Play();
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( !isUnderlay );
+
+ view.Play();
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ // If platform api doesn't provide any API or feature for decoded images of video,
+ // UNDERLAY should be true
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = false;
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( isUnderlay );
+
+ // For coverage
+ ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true );
+ view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+ isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+ DALI_TEST_CHECK( !isUnderlay );
+
+ view.Stop();
+
+ END_TEST;
+}
}\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() );
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();
}
}
#include <dali/public-api/images/native-image.h>
#include <dali/devel-api/adaptor-framework/video-player.h>
#include <dali/integration-api/adaptors/trigger-event-factory.h>
+#include <dali/public-api/object/property-notification.h>
+#include <dali/public-api/object/property-conditions.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/image/image-visual.h>
/**
* @brief Updates video display area for window rendering target
*/
- void UpdateDisplayArea();
+ void UpdateDisplayArea( Dali::PropertyNotification& source );
/**
* @brief Sets underlay flag and initializes new rendering target by flag.
std::string mUrl;
Dali::DisplayArea mDisplayArea;
Dali::Renderer mRenderer;
-
- Property::Index mUpdateTriggerPropertyIndex;
- TriggerEventInterface* mNotification;
+ Dali::PropertyNotification mPositionUpdateNotification;
+ Dali::PropertyNotification mSizeUpdateNotification;
+ Dali::PropertyNotification mScaleUpdateNotification;
int mCurrentVideoPlayPosition;
bool mIsPlay;
- bool mIsPause;
bool mIsUnderlay;
};