1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 namespace Tizen.NUI.BaseComponents
21 using System.Runtime.InteropServices;
24 /// VideoView is a control for video playback and display.
26 public class VideoView : View
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 protected override void Dispose(DisposeTypes type)
47 if(type == DisposeTypes.Explicit)
50 //Release your own managed resources here.
51 //You should release all of your own disposable objects here.
54 //Release your own unmanaged resources here.
55 //You should not access any managed member here except static instance.
56 //because the execution order of Finalizes is non-deterministic.
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
64 //Unreference this instance from Registry.
65 Registry.Unregister(this);
67 NDalicPINVOKE.delete_VideoView(swigCPtr);
69 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
76 /// Event arguments that passed via Finished signal
78 public class FinishedEventArgs : EventArgs
80 private VideoView _videoView;
83 /// The view for video playback and display.
85 public VideoView VideoView
99 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
100 private delegate void FinishedCallbackDelegate(IntPtr data);
101 private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
102 private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
106 /// Event for Finished signal which can be used to subscribe/unsubscribe the event handler
107 /// (in the type of FinishedEventHandler-DaliEventHandler<object,FinishedEventArgs>) provided by the user.<br>
108 /// Finished signal is emitted when a video playback have finished.<br>
110 public event EventHandler<FinishedEventArgs> Finished
114 if (_videoViewFinishedEventHandler == null)
116 _videoViewFinishedCallbackDelegate = (OnFinished);
117 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
119 _videoViewFinishedEventHandler += value;
123 _videoViewFinishedEventHandler -= value;
124 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
126 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
131 // Callback for VideoView Finished signal
132 private void OnFinished(IntPtr data)
134 FinishedEventArgs e = new FinishedEventArgs();
136 // Populate all members of "e" (FinishedEventArgs) with real data
137 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
139 if (_videoViewFinishedEventHandler != null)
141 //here we send all data to user event handlers
142 _videoViewFinishedEventHandler(this, e);
146 internal class Property
148 internal static readonly int VIDEO = NDalicPINVOKE.VideoView_Property_VIDEO_get();
149 internal static readonly int LOOPING = NDalicPINVOKE.VideoView_Property_LOOPING_get();
150 internal static readonly int MUTED = NDalicPINVOKE.VideoView_Property_MUTED_get();
151 internal static readonly int VOLUME = NDalicPINVOKE.VideoView_Property_VOLUME_get();
155 /// Creates an initialized VideoView.
157 public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164 /// Creates an initialized VideoView.<br>
165 /// If the string is empty, VideoView will not display anything.<br>
167 /// <param name="url">The url of the video resource to display</param>
168 public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 [Obsolete("Please do not use! this will be deprecated")]
179 public new static VideoView DownCast(BaseHandle handle)
181 VideoView ret = new VideoView(NDalicPINVOKE.VideoView_DownCast(BaseHandle.getCPtr(handle)), true);
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 /// Starts the video playback.
191 NDalicPINVOKE.VideoView_Play(swigCPtr);
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196 /// Pauses the video playback.
200 NDalicPINVOKE.VideoView_Pause(swigCPtr);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// Stops the video playback.
209 NDalicPINVOKE.VideoView_Stop(swigCPtr);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214 /// Seeks forward by the specified number of milliseconds.
216 /// <param name="millisecond">The position for forward playback</param>
217 public void Forward(int millisecond)
219 NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224 /// Seeks backward by the specified number of milliseconds.
226 /// <param name="millisecond">The position for backward playback</param>
227 public void Backward(int millisecond)
229 NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 internal VideoViewSignal FinishedSignal()
235 VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241 /// video file url as string type or PropertyMap.
243 public PropertyMap Video
247 PropertyMap temp = new PropertyMap();
248 GetProperty(VideoView.Property.VIDEO).Get(temp);
253 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
258 /// looping status, true or false.
265 GetProperty(VideoView.Property.LOOPING).Get(out temp);
270 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
275 /// mute status, true or false.
282 GetProperty(VideoView.Property.MUTED).Get(out temp);
287 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
292 /// left and right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
294 public PropertyMap Volume
298 PropertyMap temp = new PropertyMap();
299 GetProperty(VideoView.Property.VOLUME).Get(temp);
304 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));