2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using System.Runtime.InteropServices;
21 namespace Tizen.NUI.BaseComponents
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;
43 /// <param name="type">DisposeTypes</param>
44 /// <since_tizen> 3 </since_tizen>
45 protected override void Dispose(DisposeTypes type)
52 if(type == DisposeTypes.Explicit)
55 //Release your own managed resources here.
56 //You should release all of your own disposable objects here.
59 //Release your own unmanaged resources here.
60 //You should not access any managed member here except static instance.
61 //because the execution order of Finalizes is non-deterministic.
63 if (_videoViewFinishedCallbackDelegate != null)
65 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
68 if (swigCPtr.Handle != global::System.IntPtr.Zero)
73 NDalicPINVOKE.delete_VideoView(swigCPtr);
75 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
82 /// Event arguments that passed via the finished signal.
84 public class FinishedEventArgs : EventArgs
86 private VideoView _videoView;
89 /// The view for video playback and display.
91 /// <since_tizen> 3 </since_tizen>
92 public VideoView VideoView
106 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
107 private delegate void FinishedCallbackDelegate(IntPtr data);
108 private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
109 private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
113 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler
114 /// The finished signal is emitted when a video playback has finished.<br />
116 /// <since_tizen> 3 </since_tizen>
117 public event EventHandler<FinishedEventArgs> Finished
121 if (_videoViewFinishedEventHandler == null)
123 _videoViewFinishedCallbackDelegate = (OnFinished);
124 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
126 _videoViewFinishedEventHandler += value;
130 _videoViewFinishedEventHandler -= value;
131 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
133 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
138 // Callback for VideoView Finished signal
139 private void OnFinished(IntPtr data)
141 FinishedEventArgs e = new FinishedEventArgs();
143 // Populate all members of "e" (FinishedEventArgs) with real data
144 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
146 if (_videoViewFinishedEventHandler != null)
148 //here we send all data to user event handlers
149 _videoViewFinishedEventHandler(this, e);
153 internal new class Property
155 internal static readonly int VIDEO = NDalicPINVOKE.VideoView_Property_VIDEO_get();
156 internal static readonly int LOOPING = NDalicPINVOKE.VideoView_Property_LOOPING_get();
157 internal static readonly int MUTED = NDalicPINVOKE.VideoView_Property_MUTED_get();
158 internal static readonly int VOLUME = NDalicPINVOKE.VideoView_Property_VOLUME_get();
159 internal static readonly int UNDERLAY = NDalicPINVOKE.VideoView_Property_UNDERLAY_get();
163 /// Creates an initialized VideoView.
165 /// <since_tizen> 3 </since_tizen>
166 public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 /// Creates an initialized VideoView.<br />
174 /// If the string is empty, VideoView will not display anything.<br />
176 /// <param name="url">The URL of the video resource to display.</param>
177 /// <since_tizen> 3 </since_tizen>
178 public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 /// Downcasts a handle to videoView handle.
191 /// <param name="handle"></param>
192 /// <returns></returns>
193 /// Please do not use! this will be deprecated!
194 /// Instead please use as keyword.
195 [Obsolete("Please DO NOT use! This will be deprecated, instead please USE as keyword.")]
196 [EditorBrowsable(EditorBrowsableState.Never)]
197 public new static VideoView DownCast(BaseHandle handle)
199 VideoView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as VideoView;
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// Starts the video playback.
207 /// <since_tizen> 3 </since_tizen>
210 NDalicPINVOKE.VideoView_Play(swigCPtr);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Pauses the video playback.
217 /// <since_tizen> 3 </since_tizen>
220 NDalicPINVOKE.VideoView_Pause(swigCPtr);
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 /// Stops the video playback.
227 /// <since_tizen> 3 </since_tizen>
230 NDalicPINVOKE.VideoView_Stop(swigCPtr);
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235 /// Seeks forward by the specified number of milliseconds.
237 /// <param name="millisecond">The position for forward playback.</param>
238 /// <since_tizen> 3 </since_tizen>
239 public void Forward(int millisecond)
241 NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 /// Seeks backward by the specified number of milliseconds.
248 /// <param name="millisecond">The position for backward playback.</param>
249 /// <since_tizen> 3 </since_tizen>
250 public void Backward(int millisecond)
252 NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 internal VideoViewSignal FinishedSignal()
258 VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 /// Video file setting type of PropertyMap.
266 /// <since_tizen> 3 </since_tizen>
267 public PropertyMap Video
271 PropertyMap temp = new PropertyMap();
272 GetProperty(VideoView.Property.VIDEO).Get(temp);
277 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
282 /// The looping status, true or false.
284 /// <since_tizen> 3 </since_tizen>
290 GetProperty(VideoView.Property.LOOPING).Get(out temp);
295 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
300 /// The mute status, true or false.
302 /// <since_tizen> 3 </since_tizen>
308 GetProperty(VideoView.Property.MUTED).Get(out temp);
313 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
318 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
320 /// <since_tizen> 3 </since_tizen>
321 public PropertyMap Volume
325 PropertyMap temp = new PropertyMap();
326 GetProperty(VideoView.Property.VOLUME).Get(temp);
331 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
336 /// Video rendering by underlay, true or false.<br />
337 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
339 /// <since_tizen> 4 </since_tizen>
345 GetProperty(VideoView.Property.UNDERLAY).Get(out temp);
350 SetProperty(VideoView.Property.UNDERLAY, new PropertyValue(value));
355 /// Video file URL as string type.
357 /// <since_tizen> 4 </since_tizen>
358 public string ResourceUrl
363 GetProperty(VideoView.Property.VIDEO).Get(out tmp);
368 SetProperty(VideoView.Property.VIDEO, new PropertyValue(value));