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 /// <since_tizen> 3 </since_tizen>
27 public class VideoView : View
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31 internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
33 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
38 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
44 /// <param name="type">DisposeTypes</param>
45 /// <since_tizen> 3 </since_tizen>
46 protected override void Dispose(DisposeTypes type)
53 if(type == DisposeTypes.Explicit)
56 //Release your own managed resources here.
57 //You should release all of your own disposable objects here.
60 //Release your own unmanaged resources here.
61 //You should not access any managed member here except static instance.
62 //because the execution order of Finalizes is non-deterministic.
64 if (_videoViewFinishedCallbackDelegate != null)
66 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
69 if (swigCPtr.Handle != global::System.IntPtr.Zero)
74 NDalicPINVOKE.delete_VideoView(swigCPtr);
76 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
83 /// Event arguments that passed via the finished signal.
85 /// <since_tizen> 3 </since_tizen>
86 public class FinishedEventArgs : EventArgs
88 private VideoView _videoView;
91 /// The view for video playback and display.
93 /// <since_tizen> 3 </since_tizen>
94 public VideoView VideoView
108 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
109 private delegate void FinishedCallbackDelegate(IntPtr data);
110 private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
111 private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
115 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler
116 /// The finished signal is emitted when a video playback has finished.<br />
118 /// <since_tizen> 3 </since_tizen>
119 public event EventHandler<FinishedEventArgs> Finished
123 if (_videoViewFinishedEventHandler == null)
125 _videoViewFinishedCallbackDelegate = (OnFinished);
126 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
128 _videoViewFinishedEventHandler += value;
132 _videoViewFinishedEventHandler -= value;
133 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
135 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
140 // Callback for VideoView Finished signal
141 private void OnFinished(IntPtr data)
143 FinishedEventArgs e = new FinishedEventArgs();
145 // Populate all members of "e" (FinishedEventArgs) with real data
146 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
148 if (_videoViewFinishedEventHandler != null)
150 //here we send all data to user event handlers
151 _videoViewFinishedEventHandler(this, e);
155 internal new class Property
157 internal static readonly int VIDEO = NDalicPINVOKE.VideoView_Property_VIDEO_get();
158 internal static readonly int LOOPING = NDalicPINVOKE.VideoView_Property_LOOPING_get();
159 internal static readonly int MUTED = NDalicPINVOKE.VideoView_Property_MUTED_get();
160 internal static readonly int VOLUME = NDalicPINVOKE.VideoView_Property_VOLUME_get();
161 internal static readonly int UNDERLAY = NDalicPINVOKE.VideoView_Property_UNDERLAY_get();
165 /// Creates an initialized VideoView.
167 /// <since_tizen> 3 </since_tizen>
168 public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 /// Creates an initialized VideoView.<br />
176 /// If the string is empty, VideoView will not display anything.<br />
178 /// <param name="url">The URL of the video resource to display.</param>
179 /// <since_tizen> 3 </since_tizen>
180 public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 /// Downcasts a handle to videoView handle.
193 /// <param name="handle"></param>
194 /// <returns></returns>
195 /// Please do not use! this will be deprecated!
196 /// Instead please use as keyword.
197 /// <since_tizen> 3 </since_tizen>
198 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead!")]
199 [EditorBrowsable(EditorBrowsableState.Never)]
200 public new static VideoView DownCast(BaseHandle handle)
202 VideoView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as VideoView;
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 /// Starts the video playback.
210 /// <since_tizen> 3 </since_tizen>
213 NDalicPINVOKE.VideoView_Play(swigCPtr);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 /// Pauses the video playback.
220 /// <since_tizen> 3 </since_tizen>
223 NDalicPINVOKE.VideoView_Pause(swigCPtr);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228 /// Stops the video playback.
230 /// <since_tizen> 3 </since_tizen>
233 NDalicPINVOKE.VideoView_Stop(swigCPtr);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 /// Seeks forward by the specified number of milliseconds.
240 /// <param name="millisecond">The position for forward playback.</param>
241 /// <since_tizen> 3 </since_tizen>
242 public void Forward(int millisecond)
244 NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 /// Seeks backward by the specified number of milliseconds.
251 /// <param name="millisecond">The position for backward playback.</param>
252 /// <since_tizen> 3 </since_tizen>
253 public void Backward(int millisecond)
255 NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259 internal VideoViewSignal FinishedSignal()
261 VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 /// Video file setting type of PropertyMap.
269 /// <since_tizen> 3 </since_tizen>
270 public PropertyMap Video
274 PropertyMap temp = new PropertyMap();
275 GetProperty(VideoView.Property.VIDEO).Get(temp);
280 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
285 /// The looping status, true or false.
287 /// <since_tizen> 3 </since_tizen>
293 GetProperty(VideoView.Property.LOOPING).Get(out temp);
298 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
303 /// The mute status, true or false.
305 /// <since_tizen> 3 </since_tizen>
311 GetProperty(VideoView.Property.MUTED).Get(out temp);
316 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
321 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
323 /// <since_tizen> 3 </since_tizen>
324 public PropertyMap Volume
328 PropertyMap temp = new PropertyMap();
329 GetProperty(VideoView.Property.VOLUME).Get(temp);
334 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
339 /// Video rendering by underlay, true or false.<br />
340 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
342 /// <since_tizen> 4 </since_tizen>
348 GetProperty(VideoView.Property.UNDERLAY).Get(out temp);
353 SetProperty(VideoView.Property.UNDERLAY, new PropertyValue(value));
358 /// Video file URL as string type.
360 /// <since_tizen> 4 </since_tizen>
361 public string ResourceUrl
366 GetProperty(VideoView.Property.VIDEO).Get(out tmp);
371 SetProperty(VideoView.Property.VIDEO, new PropertyValue(value));