/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/video-view/video-view.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
namespace Dali
{
const char* const VOLUME_LEFT( "volumeLeft" );
const char* const VOLUME_RIGHT( "volumeRight" );
-const char* const RENDERING_TARGET( "RENDERING_TARGET" );
+const char* const RENDERING_TARGET( "renderingTarget" );
const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" );
const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" );
VideoView::VideoView()
: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
mCurrentVideoPlayPosition( 0 ),
- mSetRenderingTarget( false ),
+ mIsNativeImageTarget( true ),
mIsPlay( false ),
mIsPause( false )
{
return handle;
}
+void VideoView::OnInitialize()
+{
+ Any source;
+ Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
+ mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
+
+ mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
+ mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+}
+
void VideoView::SetUrl( const std::string& url )
{
if( mUrl != url || !mPropertyMap.Empty() )
{
- mPropertyMap.Clear();
-
mUrl = url;
+ mPropertyMap.Clear();
}
- if( mSetRenderingTarget )
- {
- mVideoPlayer.SetUrl( mUrl );
- }
- else
+ if( mIsNativeImageTarget )
{
- SetNativeImageTarget();
+ Actor self( Self() );
+ Internal::InitializeVisual( self, mVisual, mNativeImage );
}
+
+ mVideoPlayer.SetUrl( mUrl );
}
void VideoView::SetPropertyMap( Property::Map map )
mPropertyMap = map;
Actor self( Self() );
- InitializeVisual( self, mVisual, mPropertyMap );
+ Internal::InitializeVisual( self, mVisual, mPropertyMap );
Property::Value* widthValue = mPropertyMap.Find( "width" );
if( widthValue )
void VideoView::OnStageConnection( int depth )
{
- Control::OnStageConnection( depth );
-
if( mVisual )
{
CustomActor self = Self();
- mVisual.SetOnStage( self );
+ Toolkit::GetImplementation(mVisual).SetOnStage( self );
}
+
+ Control::OnStageConnection( depth );
}
void VideoView::OnStageDisconnection()
if( mVisual )
{
CustomActor self = Self();
- mVisual.SetOffStage( self );
+ Toolkit::GetImplementation(mVisual).SetOffStage( self );
}
Control::OnStageDisconnection();
Actor self = Self();
int curPos = mVideoPlayer.GetPlayPosition();
- mSetRenderingTarget = true;
- mVisual.RemoveAndReset( self );
+ if( mVisual )
+ {
+ Toolkit::GetImplementation(mVisual).SetOffStage(self);
+ mVisual.Reset();
+ }
mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
mVideoPlayer.SetUrl( mUrl );
- mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
+
+ mIsNativeImageTarget = false;
if( mIsPlay )
{
Actor self( Self() );
int curPos = mVideoPlayer.GetPlayPosition();
- mSetRenderingTarget = true;
-
Any source;
Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source );
mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr );
mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr );
mVideoPlayer.SetUrl( mUrl );
- mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
- InitializeVisual( self, mVisual, mNativeImage );
+ Internal::InitializeVisual( self, mVisual, mNativeImage );
+ mIsNativeImageTarget = true;
if( mIsPlay )
{