X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Fpublic%2FBaseComponents%2FVideoView.cs;h=d54c56ca68efb39615b352f0e0bbd0deb05aed88;hb=8024def7eb53ab6c88704ac719a607ff7ab7f396;hp=6a83b5049be4e133db2698522ddb15c3aa1078df;hpb=013550adda2b112b0b8aba069d01b0d8d43e554e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.NUI/src/public/BaseComponents/VideoView.cs b/src/Tizen.NUI/src/public/BaseComponents/VideoView.cs index 6a83b50..d54c56c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/VideoView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/VideoView.cs @@ -29,109 +29,109 @@ namespace Tizen.NUI.BaseComponents { /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty VideoProperty = BindableProperty.Create(nameof(Video), typeof(PropertyMap), typeof(VideoView), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty VideoProperty = BindableProperty.Create(nameof(Video), typeof(PropertyMap), typeof(VideoView), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => { var videoView = (VideoView)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((PropertyMap)newValue)); + Tizen.NUI.Object.SetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((PropertyMap)newValue)); } - }, - defaultValueCreator: (bindable) => + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var videoView = (VideoView)bindable; PropertyMap temp = new PropertyMap(); - Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VIDEO).Get(temp); + Tizen.NUI.Object.GetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.VIDEO).Get(temp); return temp; - }); + })); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty LoopingProperty = BindableProperty.Create(nameof(Looping), typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty LoopingProperty = BindableProperty.Create(nameof(Looping), typeof(bool), typeof(VideoView), false, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => { var videoView = (VideoView)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue((bool)newValue)); + Tizen.NUI.Object.SetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue((bool)newValue)); } - }, - defaultValueCreator: (bindable) => + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var videoView = (VideoView)bindable; bool temp = false; - Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.LOOPING).Get(out temp); + Tizen.NUI.Object.GetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.LOOPING).Get(out temp); return temp; - }); + })); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty MutedProperty = BindableProperty.Create(nameof(Muted), typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty MutedProperty = BindableProperty.Create(nameof(Muted), typeof(bool), typeof(VideoView), false, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => { var videoView = (VideoView)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.MUTED, new Tizen.NUI.PropertyValue((bool)newValue)); + Tizen.NUI.Object.SetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.MUTED, new Tizen.NUI.PropertyValue((bool)newValue)); } - }, - defaultValueCreator: (bindable) => + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var videoView = (VideoView)bindable; bool temp = false; - Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.MUTED).Get(out temp); + Tizen.NUI.Object.GetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.MUTED).Get(out temp); return temp; - }); + })); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty VolumeProperty = BindableProperty.Create(nameof(Volume), typeof(PropertyMap), typeof(VideoView), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty VolumeProperty = BindableProperty.Create(nameof(Volume), typeof(PropertyMap), typeof(VideoView), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => { var videoView = (VideoView)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VOLUME, new Tizen.NUI.PropertyValue((PropertyMap)newValue)); + Tizen.NUI.Object.SetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.VOLUME, new Tizen.NUI.PropertyValue((PropertyMap)newValue)); } - }, - defaultValueCreator: (bindable) => + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var videoView = (VideoView)bindable; PropertyMap temp = new PropertyMap(); - Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VOLUME).Get(temp); + Tizen.NUI.Object.GetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.VOLUME).Get(temp); return temp; - }); + })); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty UnderlayProperty = BindableProperty.Create(nameof(Underlay), typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty UnderlayProperty = BindableProperty.Create(nameof(Underlay), typeof(bool), typeof(VideoView), false, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => { var videoView = (VideoView)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.UNDERLAY, new Tizen.NUI.PropertyValue((bool)newValue)); + Tizen.NUI.Object.SetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.UNDERLAY, new Tizen.NUI.PropertyValue((bool)newValue)); } - }, - defaultValueCreator: (bindable) => + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var videoView = (VideoView)bindable; bool temp = false; - Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.UNDERLAY).Get(out temp); + Tizen.NUI.Object.GetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.UNDERLAY).Get(out temp); return temp; - }); + })); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ResourceUrl), typeof(string), typeof(VideoView), string.Empty, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ResourceUrl), typeof(string), typeof(VideoView), string.Empty, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => { var videoView = (VideoView)bindable; if (newValue != null) { - Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((string)newValue)); + Tizen.NUI.Object.SetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((string)newValue)); } - }, - defaultValueCreator: (bindable) => + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => { var videoView = (VideoView)bindable; string temp; - Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VIDEO).Get(out temp); + Tizen.NUI.Object.GetProperty((HandleRef)videoView.SwigCPtr, VideoView.Property.VIDEO).Get(out temp); return temp; - }); + })); - private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate; - private EventHandler _videoViewFinishedEventHandler; + private FinishedCallbackDelegate videoViewFinishedCallbackDelegate; + private EventHandler videoViewFinishedEventHandler; /// /// Creates an initialized VideoView. @@ -176,16 +176,30 @@ namespace Tizen.NUI.BaseComponents if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + /// + /// Hidden API (Inhouse API). + /// Using Uri class to provide safe service and secure API. + /// Creates an initialized VideoView. + /// If the string is empty, VideoView will not display anything. + /// + /// The URI of the video resource to display. + /// Video rendering by H/W codec if false. + [EditorBrowsable(EditorBrowsableState.Never)] + public VideoView(Uri uri, bool swCodec) : this(Interop.VideoView.New((uri == null) ? String.Empty : uri.AbsoluteUri, swCodec), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + internal VideoView(VideoView videoView) : this(Interop.VideoView.NewVideoView(VideoView.getCPtr(videoView)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.VideoView.Upcast(cPtr), cMemoryOwn) + internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { } - [UnmanagedFunctionPointer(CallingConvention.StdCall)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void FinishedCallbackDelegate(IntPtr data); /// @@ -197,19 +211,19 @@ namespace Tizen.NUI.BaseComponents { add { - if (_videoViewFinishedEventHandler == null) + if (videoViewFinishedEventHandler == null) { - _videoViewFinishedCallbackDelegate = (OnFinished); - FinishedSignal().Connect(_videoViewFinishedCallbackDelegate); + videoViewFinishedCallbackDelegate = (OnFinished); + FinishedSignal().Connect(videoViewFinishedCallbackDelegate); } - _videoViewFinishedEventHandler += value; + videoViewFinishedEventHandler += value; } remove { - _videoViewFinishedEventHandler -= value; - if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false) + videoViewFinishedEventHandler -= value; + if (videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false) { - FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate); + FinishedSignal().Disconnect(videoViewFinishedCallbackDelegate); } } } @@ -323,7 +337,7 @@ namespace Tizen.NUI.BaseComponents /// 3 public void Play() { - Interop.VideoView.Play(swigCPtr); + Interop.VideoView.Play(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -333,7 +347,7 @@ namespace Tizen.NUI.BaseComponents /// 3 public void Pause() { - Interop.VideoView.Pause(swigCPtr); + Interop.VideoView.Pause(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -343,7 +357,7 @@ namespace Tizen.NUI.BaseComponents /// 3 public void Stop() { - Interop.VideoView.Stop(swigCPtr); + Interop.VideoView.Stop(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -354,7 +368,7 @@ namespace Tizen.NUI.BaseComponents /// 3 public void Forward(int millisecond) { - Interop.VideoView.Forward(swigCPtr, millisecond); + Interop.VideoView.Forward(SwigCPtr, millisecond); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -365,20 +379,40 @@ namespace Tizen.NUI.BaseComponents /// 3 public void Backward(int millisecond) { - Interop.VideoView.Backward(swigCPtr, millisecond); + Interop.VideoView.Backward(SwigCPtr, millisecond); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal VideoViewSignal FinishedSignal() + /// + /// Get native player handle. + /// + /// How to get native player handle + /// + /// VideoView videoView = new VideoView(); + /// videoView.ResourceUrl = "some video path"; + /// var handle = videoView.NativeHandle; + /// if(handle.IsInvalid == false) + /// { + /// IntPtr nativeHandle = handle.DangerousGetHandle(); + /// // do something with nativeHandle + /// } + /// + /// + /// + /// 9 + public SafeHandle NativeHandle { - VideoViewSignal ret = new VideoViewSignal(Interop.VideoView.FinishedSignal(swigCPtr), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; + get + { + return new NUI.SafeNativePlayerHandle(this); + } } - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj) + internal VideoViewSignal FinishedSignal() { - return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + VideoViewSignal ret = new VideoViewSignal(Interop.VideoView.FinishedSignal(SwigCPtr), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } /// @@ -397,9 +431,9 @@ namespace Tizen.NUI.BaseComponents //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. - if (this != null && _videoViewFinishedCallbackDelegate != null) + if (this != null && videoViewFinishedCallbackDelegate != null) { - FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate); + FinishedSignal().Disconnect(videoViewFinishedCallbackDelegate); } base.Dispose(type); @@ -415,15 +449,14 @@ namespace Tizen.NUI.BaseComponents // Callback for VideoView Finished signal private void OnFinished(IntPtr data) { - FinishedEventArgs e = new FinishedEventArgs(); - - // Populate all members of "e" (FinishedEventArgs) with real data - e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView; - - if (_videoViewFinishedEventHandler != null) + if (videoViewFinishedEventHandler != null) { + FinishedEventArgs e = new FinishedEventArgs(); + + // Populate all members of "e" (FinishedEventArgs) with real data + e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView; //here we send all data to user event handlers - _videoViewFinishedEventHandler(this, e); + videoViewFinishedEventHandler(this, e); } } @@ -433,7 +466,7 @@ namespace Tizen.NUI.BaseComponents /// 3 public class FinishedEventArgs : EventArgs { - private VideoView _videoView; + private VideoView videoView; /// /// The view for video playback and display. @@ -443,11 +476,11 @@ namespace Tizen.NUI.BaseComponents { get { - return _videoView; + return videoView; } set { - _videoView = value; + videoView = value; } } } @@ -463,7 +496,7 @@ namespace Tizen.NUI.BaseComponents internal System.IntPtr GetNativePlayerHandle() { - var ret = Interop.VideoView.GetNativePlayerHandle(swigCPtr); + var ret = Interop.VideoView.GetNativePlayerHandle(SwigCPtr); NUILog.Debug($"NativePlayerHandle=0x{ret:X}"); return ret; } @@ -473,10 +506,11 @@ namespace Tizen.NUI.BaseComponents /// Contains and encapsulates Native Player handle. /// [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This has been deprecated in API9 and will be removed in API11. Use VideoView.NativeHandle instead.")] public class SafeNativePlayerHandle : SafeHandle { /// - /// Contructor, null handle is set. + /// Constructor, null handle is set. /// [EditorBrowsable(EditorBrowsableState.Never)] public SafeNativePlayerHandle() : base(global::System.IntPtr.Zero, false) @@ -484,7 +518,7 @@ namespace Tizen.NUI.BaseComponents } /// - /// Contructor, Native player handle is set to handle. + /// Constructor, Native player handle is set to handle. /// [EditorBrowsable(EditorBrowsableState.Never)] public SafeNativePlayerHandle(VideoView videoView) : base(global::System.IntPtr.Zero, false)