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;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
25 /// VideoView is a control for video playback and display.
27 /// <since_tizen> 3 </since_tizen>
28 public class VideoView : View
30 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public static readonly BindableProperty VideoProperty = BindableProperty.Create("Video", typeof(PropertyMap), typeof(VideoView), null, propertyChanged: (bindable, oldValue, newValue) =>
34 var videoView = (VideoView)bindable;
37 Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
40 defaultValueCreator: (bindable) =>
42 var videoView = (VideoView)bindable;
43 PropertyMap temp = new PropertyMap();
44 Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VIDEO).Get(temp);
47 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
48 [EditorBrowsable(EditorBrowsableState.Never)]
49 public static readonly BindableProperty LoopingProperty = BindableProperty.Create("Looping", typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) =>
51 var videoView = (VideoView)bindable;
54 Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue((bool)newValue));
57 defaultValueCreator: (bindable) =>
59 var videoView = (VideoView)bindable;
61 Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.LOOPING).Get(out temp);
64 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
65 [EditorBrowsable(EditorBrowsableState.Never)]
66 public static readonly BindableProperty MutedProperty = BindableProperty.Create("Muted", typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) =>
68 var videoView = (VideoView)bindable;
71 Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.MUTED, new Tizen.NUI.PropertyValue((bool)newValue));
74 defaultValueCreator: (bindable) =>
76 var videoView = (VideoView)bindable;
78 Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.MUTED).Get(out temp);
81 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
82 [EditorBrowsable(EditorBrowsableState.Never)]
83 public static readonly BindableProperty VolumeProperty = BindableProperty.Create("Volume", typeof(PropertyMap), typeof(VideoView), null, propertyChanged: (bindable, oldValue, newValue) =>
85 var videoView = (VideoView)bindable;
88 Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VOLUME, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
91 defaultValueCreator: (bindable) =>
93 var videoView = (VideoView)bindable;
94 PropertyMap temp = new PropertyMap();
95 Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VOLUME).Get(temp);
98 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
99 [EditorBrowsable(EditorBrowsableState.Never)]
100 public static readonly BindableProperty UnderlayProperty = BindableProperty.Create("Underlay", typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) =>
102 var videoView = (VideoView)bindable;
103 if (newValue != null)
105 Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.UNDERLAY, new Tizen.NUI.PropertyValue((bool)newValue));
108 defaultValueCreator: (bindable) =>
110 var videoView = (VideoView)bindable;
112 Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.UNDERLAY).Get(out temp);
115 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
116 [EditorBrowsable(EditorBrowsableState.Never)]
117 public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create("ResourceUrl", typeof(string), typeof(VideoView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
119 var videoView = (VideoView)bindable;
120 if (newValue != null)
122 Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((string)newValue));
125 defaultValueCreator: (bindable) =>
127 var videoView = (VideoView)bindable;
129 Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VIDEO).Get(out temp);
133 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
134 private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
135 private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
138 /// Creates an initialized VideoView.
140 /// <since_tizen> 3 </since_tizen>
141 public VideoView() : this(Interop.VideoView.VideoView_New__SWIG_0(), true)
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 /// Creates an initialized VideoView.<br />
148 /// If the string is empty, VideoView will not display anything.<br />
150 /// <param name="url">The URL of the video resource to display.</param>
151 /// <since_tizen> 3 </since_tizen>
152 public VideoView(string url) : this(Interop.VideoView.VideoView_New__SWIG_1(url), true)
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 internal VideoView(VideoView videoView) : this(Interop.VideoView.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.VideoView.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
164 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
167 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
168 private delegate void FinishedCallbackDelegate(IntPtr data);
171 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler
172 /// The finished signal is emitted when a video playback has finished.<br />
174 /// <since_tizen> 3 </since_tizen>
175 public event EventHandler<FinishedEventArgs> Finished
179 if (_videoViewFinishedEventHandler == null)
181 _videoViewFinishedCallbackDelegate = (OnFinished);
182 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
184 _videoViewFinishedEventHandler += value;
188 _videoViewFinishedEventHandler -= value;
189 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
191 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
197 /// Video file setting type of PropertyMap.
199 /// <since_tizen> 3 </since_tizen>
200 public PropertyMap Video
204 return (PropertyMap)GetValue(VideoProperty);
208 SetValue(VideoProperty, value);
209 NotifyPropertyChanged();
214 /// The looping status, true or false.
216 /// <since_tizen> 3 </since_tizen>
221 return (bool)GetValue(LoopingProperty);
225 SetValue(LoopingProperty, value);
226 NotifyPropertyChanged();
231 /// The mute status, true or false.
233 /// <since_tizen> 3 </since_tizen>
238 return (bool)GetValue(MutedProperty);
242 SetValue(MutedProperty, value);
243 NotifyPropertyChanged();
248 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
250 /// <since_tizen> 3 </since_tizen>
251 public PropertyMap Volume
255 return (PropertyMap)GetValue(VolumeProperty);
259 SetValue(VolumeProperty, value);
260 NotifyPropertyChanged();
265 /// Video rendering by underlay, true or false.<br />
266 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
268 /// <since_tizen> 4 </since_tizen>
273 return (bool)GetValue(UnderlayProperty);
277 SetValue(UnderlayProperty, value);
278 NotifyPropertyChanged();
283 /// Video file URL as string type.
285 /// <since_tizen> 4 </since_tizen>
286 public string ResourceUrl
290 return (string)GetValue(ResourceUrlProperty);
294 SetValue(ResourceUrlProperty, value);
295 NotifyPropertyChanged();
300 /// Starts the video playback.
302 /// <since_tizen> 3 </since_tizen>
305 Interop.VideoView.VideoView_Play(swigCPtr);
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 /// Pauses the video playback.
312 /// <since_tizen> 3 </since_tizen>
315 Interop.VideoView.VideoView_Pause(swigCPtr);
316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
320 /// Stops the video playback.
322 /// <since_tizen> 3 </since_tizen>
325 Interop.VideoView.VideoView_Stop(swigCPtr);
326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 /// Seeks forward by the specified number of milliseconds.
332 /// <param name="millisecond">The position for forward playback.</param>
333 /// <since_tizen> 3 </since_tizen>
334 public void Forward(int millisecond)
336 Interop.VideoView.VideoView_Forward(swigCPtr, millisecond);
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 /// Seeks backward by the specified number of milliseconds.
343 /// <param name="millisecond">The position for backward playback.</param>
344 /// <since_tizen> 3 </since_tizen>
345 public void Backward(int millisecond)
347 Interop.VideoView.VideoView_Backward(swigCPtr, millisecond);
348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351 internal VideoViewSignal FinishedSignal()
353 VideoViewSignal ret = new VideoViewSignal(Interop.VideoView.VideoView_FinishedSignal(swigCPtr), false);
354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
360 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
366 /// <param name="type">DisposeTypes</param>
367 /// <since_tizen> 3 </since_tizen>
368 protected override void Dispose(DisposeTypes type)
375 if (type == DisposeTypes.Explicit)
378 //Release your own managed resources here.
379 //You should release all of your own disposable objects here.
382 //Release your own unmanaged resources here.
383 //You should not access any managed member here except static instance.
384 //because the execution order of Finalizes is non-deterministic.
386 if (this != null && _videoViewFinishedCallbackDelegate != null)
388 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
391 if (swigCPtr.Handle != global::System.IntPtr.Zero)
396 Interop.VideoView.delete_VideoView(swigCPtr);
398 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
404 // Callback for VideoView Finished signal
405 private void OnFinished(IntPtr data)
407 FinishedEventArgs e = new FinishedEventArgs();
409 // Populate all members of "e" (FinishedEventArgs) with real data
410 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
412 if (_videoViewFinishedEventHandler != null)
414 //here we send all data to user event handlers
415 _videoViewFinishedEventHandler(this, e);
420 /// Event arguments that passed via the finished signal.
422 /// <since_tizen> 3 </since_tizen>
423 public class FinishedEventArgs : EventArgs
425 private VideoView _videoView;
428 /// The view for video playback and display.
430 /// <since_tizen> 3 </since_tizen>
431 public VideoView VideoView
444 internal new class Property
446 internal static readonly int VIDEO = Interop.VideoView.VideoView_Property_VIDEO_get();
447 internal static readonly int LOOPING = Interop.VideoView.VideoView_Property_LOOPING_get();
448 internal static readonly int MUTED = Interop.VideoView.VideoView_Property_MUTED_get();
449 internal static readonly int VOLUME = Interop.VideoView.VideoView_Property_VOLUME_get();
450 internal static readonly int UNDERLAY = Interop.VideoView.VideoView_Property_UNDERLAY_get();