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 namespace Tizen.NUI.BaseComponents
22 using System.Runtime.InteropServices;
25 /// VideoView is a control for video playback and display.
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 public class FinishedEventArgs : EventArgs
87 private VideoView _videoView;
90 /// The view for video playback and display.
92 /// <since_tizen> 3 </since_tizen>
93 public VideoView VideoView
107 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
108 private delegate void FinishedCallbackDelegate(IntPtr data);
109 private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
110 private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
114 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler
115 /// The finished signal is emitted when a video playback has finished.<br />
117 /// <since_tizen> 3 </since_tizen>
118 public event EventHandler<FinishedEventArgs> Finished
122 if (_videoViewFinishedEventHandler == null)
124 _videoViewFinishedCallbackDelegate = (OnFinished);
125 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
127 _videoViewFinishedEventHandler += value;
131 _videoViewFinishedEventHandler -= value;
132 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
134 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
139 // Callback for VideoView Finished signal
140 private void OnFinished(IntPtr data)
142 FinishedEventArgs e = new FinishedEventArgs();
144 // Populate all members of "e" (FinishedEventArgs) with real data
145 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
147 if (_videoViewFinishedEventHandler != null)
149 //here we send all data to user event handlers
150 _videoViewFinishedEventHandler(this, e);
154 internal new class Property
156 internal static readonly int VIDEO = NDalicPINVOKE.VideoView_Property_VIDEO_get();
157 internal static readonly int LOOPING = NDalicPINVOKE.VideoView_Property_LOOPING_get();
158 internal static readonly int MUTED = NDalicPINVOKE.VideoView_Property_MUTED_get();
159 internal static readonly int VOLUME = NDalicPINVOKE.VideoView_Property_VOLUME_get();
160 internal static readonly int UNDERLAY = NDalicPINVOKE.VideoView_Property_UNDERLAY_get();
164 /// Creates an initialized VideoView.
166 /// <since_tizen> 3 </since_tizen>
167 public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 /// Creates an initialized VideoView.<br />
175 /// If the string is empty, VideoView will not display anything.<br />
177 /// <param name="url">The URL of the video resource to display.</param>
178 /// <since_tizen> 3 </since_tizen>
179 public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// [Obsolete("Please do not use! this will be deprecated")]
192 /// <param name="handle"></param>
193 /// <returns></returns>
194 [Obsolete("Please do not use! this will be deprecated")]
195 public new static VideoView DownCast(BaseHandle handle)
197 VideoView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as VideoView;
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 /// Starts the video playback.
205 /// <since_tizen> 3 </since_tizen>
208 NDalicPINVOKE.VideoView_Play(swigCPtr);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 /// Pauses the video playback.
215 /// <since_tizen> 3 </since_tizen>
218 NDalicPINVOKE.VideoView_Pause(swigCPtr);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 /// Stops the video playback.
225 /// <since_tizen> 3 </since_tizen>
228 NDalicPINVOKE.VideoView_Stop(swigCPtr);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// Seeks forward by the specified number of milliseconds.
235 /// <param name="millisecond">The position for forward playback.</param>
236 /// <since_tizen> 3 </since_tizen>
237 public void Forward(int millisecond)
239 NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 /// Seeks backward by the specified number of milliseconds.
246 /// <param name="millisecond">The position for backward playback.</param>
247 /// <since_tizen> 3 </since_tizen>
248 public void Backward(int millisecond)
250 NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 internal VideoViewSignal FinishedSignal()
256 VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 /// Video file setting type of PropertyMap.
264 /// <since_tizen> 3 </since_tizen>
265 public PropertyMap Video
269 PropertyMap temp = new PropertyMap();
270 GetProperty(VideoView.Property.VIDEO).Get(temp);
275 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
280 /// The looping status, true or false.
282 /// <since_tizen> 3 </since_tizen>
288 GetProperty(VideoView.Property.LOOPING).Get(out temp);
293 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
298 /// The mute status, true or false.
300 /// <since_tizen> 3 </since_tizen>
306 GetProperty(VideoView.Property.MUTED).Get(out temp);
311 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
316 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
318 /// <since_tizen> 3 </since_tizen>
319 public PropertyMap Volume
323 PropertyMap temp = new PropertyMap();
324 GetProperty(VideoView.Property.VOLUME).Get(temp);
329 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
334 /// Video rendering by underlay, true or false.<br />
335 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
337 /// <since_tizen> 4 </since_tizen>
343 GetProperty(VideoView.Property.UNDERLAY).Get(out temp);
348 SetProperty(VideoView.Property.UNDERLAY, new PropertyValue(value));
353 /// Video file URL as string type.
355 /// <since_tizen> 4 </since_tizen>
356 public string ResourceUrl
361 GetProperty(VideoView.Property.VIDEO).Get(out tmp);
366 SetProperty(VideoView.Property.VIDEO, new PropertyValue(value));