// EXTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/devel-api/rendering/texture-devel.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
const char* const DEFAULT_SAMPLER_TYPE_NAME("sampler2D");
const char* const CUSTOM_SAMPLER_TYPE_NAME("samplerExternalOES");
+const char* const IS_VIDEO_VIEW_PROPERTY_NAME = "isVideoView";
+
} // namespace
VideoView::VideoView(Dali::VideoSyncMode syncMode)
mFrameID(0),
mIsPlay(false),
mIsUnderlay(true),
- mSyncMode(syncMode)
+ mSyncMode(syncMode),
+ mSiblingOrder(0)
{
}
void VideoView::OnInitialize()
{
+ Actor self = Self();
mVideoPlayer.FinishedSignal().Connect(this, &VideoView::EmitSignalFinish);
- DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
+ DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) {
return std::unique_ptr<Dali::Accessibility::Accessible>(
new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::VIDEO));
});
+
+ //Enable highightability
+ Self().SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true);
+
+ //update self property
+ self.RegisterProperty(IS_VIDEO_VIEW_PROPERTY_NAME, true, Property::READ_WRITE);
}
void VideoView::SetUrl(const std::string& url)
void VideoView::OnSceneConnection(int depth)
{
- Control::OnSceneConnection(depth);
-
+ Actor self = Self();
if(mIsUnderlay)
{
+ mSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+ DevelActor::ChildOrderChangedSignal(self.GetParent()).Connect(this, &VideoView::OnChildOrderChanged);
SetWindowSurfaceTarget();
}
+
+ Control::OnSceneConnection(depth);
}
void VideoView::OnSceneDisconnection()
Control::OnSizeSet(targetSize);
}
+void VideoView::OnChildOrderChanged(Actor actor)
+{
+ Actor self = Self();
+ int currentSiblingOrder = self.GetProperty<int>(Dali::DevelActor::Property::SIBLING_ORDER);
+ if(currentSiblingOrder != mSiblingOrder)
+ {
+ Actor parent = self.GetParent();
+ Actor child;
+ Actor upper;
+ Actor lower;
+
+ int numChildren = static_cast<int>(parent.GetChildCount());
+ for(int i = 0; i < numChildren; i++)
+ {
+ child = parent.GetChildAt(i);
+ if(!IsVideoView(child))
+ {
+ continue;
+ }
+
+ if(child == self)
+ {
+ continue;
+ }
+
+ if(i < currentSiblingOrder)
+ {
+ lower = child;
+ }
+ else if(i > currentSiblingOrder)
+ {
+ upper = child;
+ break;
+ }
+ }
+
+ if(lower)
+ {
+ Toolkit::VideoView lowerView = Toolkit::VideoView::DownCast(lower);
+ mVideoPlayer.RaiseAbove(GetImpl(lowerView).GetVideoPlayer());
+ }
+
+ if(upper)
+ {
+ Toolkit::VideoView upperView = Toolkit::VideoView::DownCast(upper);
+ mVideoPlayer.LowerBelow(GetImpl(upperView).GetVideoPlayer());
+ }
+ mSiblingOrder = currentSiblingOrder;
+ }
+}
+
Vector3 VideoView::GetNaturalSize()
{
Vector3 size;
return;
}
+ Dali::Window window = DevelWindow::Get(self);
+ window.ResizeSignal().Connect(this, &VideoView::OnWindowResized);
+
int curPos = mVideoPlayer.GetPlayPosition();
if(mIsPlay)
SetFrameRenderCallback();
}
+void VideoView::OnWindowResized(Dali::Window winHandle, Dali::Window::WindowSize size)
+{
+ Dali::VideoPlayerPlugin::DisplayRotation videoAngle = mVideoPlayer.GetDisplayRotation();
+ int windowAngle = (DevelWindow::GetPhysicalOrientation(winHandle) / 90);
+
+ if(windowAngle != videoAngle)
+ {
+ mVideoPlayer.SetDisplayRotation(static_cast<Dali::VideoPlayerPlugin::DisplayRotation>(windowAngle));
+ }
+}
+
void VideoView::PlayAnimation(Dali::Animation animation)
{
if(mIsUnderlay && mSyncMode == Dali::VideoSyncMode::ENABLED)
Dali::Shader VideoView::CreateShader()
{
- std::string fragmentShader = "#extension GL_OES_EGL_image_external:require\n";
+ std::string fragmentShader;
std::string vertexShader;
std::string customFragmentShader;
bool checkShader = false;
if(!fragmentShaderValue || !checkShader)
{
- fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader);
}
}
else
{
- vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
- fragmentShader += SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ vertexShader = SHADER_VIDEO_VIEW_TEXTURE_VERT.data();
+ fragmentShader = SHADER_VIDEO_VIEW_TEXTURE_FRAG.data();
+ DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader);
}
return Dali::Shader::New(vertexShader, fragmentShader);
mFrameID);
}
+bool VideoView::IsVideoView(Actor actor) const
+{
+ // Check whether the actor is a VideoView
+ bool isVideoView = false;
+
+ if(actor)
+ {
+ Property::Index propertyIsVideoView = actor.GetPropertyIndex(IS_VIDEO_VIEW_PROPERTY_NAME);
+ if(propertyIsVideoView != Property::INVALID_INDEX)
+ {
+ isVideoView = actor.GetProperty<bool>(propertyIsVideoView);
+ }
+ }
+
+ return isVideoView;
+}
+
+VideoPlayer VideoView::GetVideoPlayer()
+{
+ return mVideoPlayer;
+}
+
} // namespace Internal
} // namespace Toolkit