/** 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ namespace Tizen.NUI.BaseComponents { using System; using System.Runtime.InteropServices; /// /// VideoView is a control for video playback and display. /// public class VideoView : View { private global::System.Runtime.InteropServices.HandleRef swigCPtr; internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VideoView_SWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } protected override void Dispose(DisposeTypes type) { if(disposed) { return; } if(type == DisposeTypes.Explicit) { //Called by User //Release your own managed resources here. //You should release all of your own disposable objects here. } //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. if (_videoViewFinishedCallbackDelegate != null) { FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate); } if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { swigCMemOwn = false; NDalicPINVOKE.delete_VideoView(swigCPtr); } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } base.Dispose(type); } /// /// Event arguments that passed via the finished signal. /// public class FinishedEventArgs : EventArgs { private VideoView _videoView; /// /// The view for video playback and display. /// public VideoView VideoView { get { return _videoView; } set { _videoView = value; } } } [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void FinishedCallbackDelegate(IntPtr data); private EventHandler _videoViewFinishedEventHandler; private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate; /// /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler /// (in the type of FinishedEventHandler-DaliEventHandler) provided by the user.
/// The finished signal is emitted when a video playback has finished.
///
public event EventHandler Finished { add { if (_videoViewFinishedEventHandler == null) { _videoViewFinishedCallbackDelegate = (OnFinished); FinishedSignal().Connect(_videoViewFinishedCallbackDelegate); } _videoViewFinishedEventHandler += value; } remove { _videoViewFinishedEventHandler -= value; if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false) { FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate); } } } // 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) { //here we send all data to user event handlers _videoViewFinishedEventHandler(this, e); } } internal new class Property { internal static readonly int VIDEO = NDalicPINVOKE.VideoView_Property_VIDEO_get(); internal static readonly int LOOPING = NDalicPINVOKE.VideoView_Property_LOOPING_get(); internal static readonly int MUTED = NDalicPINVOKE.VideoView_Property_MUTED_get(); internal static readonly int VOLUME = NDalicPINVOKE.VideoView_Property_VOLUME_get(); } /// /// Creates an initialized VideoView. /// public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Creates an initialized VideoView.
/// If the string is empty, VideoView will not display anything.
///
/// The URL of the video resource to display. public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } [Obsolete("Please do not use! this will be deprecated")] public new static VideoView DownCast(BaseHandle handle) { VideoView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as VideoView; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Starts the video playback. /// public void Play() { NDalicPINVOKE.VideoView_Play(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Pauses the video playback. /// public void Pause() { NDalicPINVOKE.VideoView_Pause(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Stops the video playback. /// public void Stop() { NDalicPINVOKE.VideoView_Stop(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Seeks forward by the specified number of milliseconds. /// /// The position for forward playback. public void Forward(int millisecond) { NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Seeks backward by the specified number of milliseconds. /// /// The position for backward playback. public void Backward(int millisecond) { NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal VideoViewSignal FinishedSignal() { VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Video file URL as string type or PropertyMap. /// public PropertyMap Video { get { PropertyMap temp = new PropertyMap(); GetProperty(VideoView.Property.VIDEO).Get(temp); return temp; } set { SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value)); } } /// /// The looping status, true or false. /// public bool Looping { get { bool temp = false; GetProperty(VideoView.Property.LOOPING).Get(out temp); return temp; } set { SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value)); } } /// /// The mute status, true or false. /// public bool Muted { get { bool temp = false; GetProperty(VideoView.Property.MUTED).Get(out temp); return temp; } set { SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value)); } } /// /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ). /// public PropertyMap Volume { get { PropertyMap temp = new PropertyMap(); GetProperty(VideoView.Property.VOLUME).Get(temp); return temp; } set { SetProperty(VideoView.Property.VOLUME, new PropertyValue(value)); } } } }