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 FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
134 private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
137 /// Creates an initialized VideoView.
139 /// <since_tizen> 3 </since_tizen>
140 public VideoView() : this(Interop.VideoView.VideoView_New__SWIG_0(), true)
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 /// Creates an initialized VideoView.<br />
147 /// If the string is empty, VideoView will not display anything.<br />
149 /// <param name="url">The URL of the video resource to display.</param>
150 /// <since_tizen> 3 </since_tizen>
151 public VideoView(string url) : this(Interop.VideoView.VideoView_New__SWIG_1(url), true)
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 /// Creates an initialized VideoView.<br />
158 /// If the string is empty, VideoView will not display anything.<br />
160 /// <param name="swCodec">Video rendering by H/W codec if false.</param>
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public VideoView(bool swCodec) : this(Interop.VideoView.VideoView_New__SWIG_2(swCodec), true)
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 /// Creates an initialized VideoView.<br />
169 /// If the string is empty, VideoView will not display anything.<br />
171 /// <param name="url">The URL of the video resource to display.</param>
172 /// <param name="swCodec">Video rendering by H/W codec if false.</param>
173 [EditorBrowsable(EditorBrowsableState.Never)]
174 public VideoView(string url, bool swCodec) : this(Interop.VideoView.VideoView_New__SWIG_3(url, swCodec), true)
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 internal VideoView(VideoView videoView) : this(Interop.VideoView.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.VideoView.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
188 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
189 private delegate void FinishedCallbackDelegate(IntPtr data);
192 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler
193 /// The finished signal is emitted when a video playback has finished.<br />
195 /// <since_tizen> 3 </since_tizen>
196 public event EventHandler<FinishedEventArgs> Finished
200 if (_videoViewFinishedEventHandler == null)
202 _videoViewFinishedCallbackDelegate = (OnFinished);
203 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
205 _videoViewFinishedEventHandler += value;
209 _videoViewFinishedEventHandler -= value;
210 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
212 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
218 /// Video file setting type of PropertyMap.
220 /// <since_tizen> 3 </since_tizen>
221 public PropertyMap Video
225 return (PropertyMap)GetValue(VideoProperty);
229 SetValue(VideoProperty, value);
230 NotifyPropertyChanged();
235 /// The looping status, true or false.
237 /// <since_tizen> 3 </since_tizen>
242 return (bool)GetValue(LoopingProperty);
246 SetValue(LoopingProperty, value);
247 NotifyPropertyChanged();
252 /// The mute status, true or false.
254 /// <since_tizen> 3 </since_tizen>
259 return (bool)GetValue(MutedProperty);
263 SetValue(MutedProperty, value);
264 NotifyPropertyChanged();
269 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
271 /// <since_tizen> 3 </since_tizen>
272 public PropertyMap Volume
276 return (PropertyMap)GetValue(VolumeProperty);
280 SetValue(VolumeProperty, value);
281 NotifyPropertyChanged();
286 /// Video rendering by underlay, true or false.<br />
287 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
289 /// <since_tizen> 4 </since_tizen>
294 return (bool)GetValue(UnderlayProperty);
298 SetValue(UnderlayProperty, value);
299 NotifyPropertyChanged();
304 /// Video file URL as string type.
306 /// <since_tizen> 4 </since_tizen>
307 public string ResourceUrl
311 return (string)GetValue(ResourceUrlProperty);
315 SetValue(ResourceUrlProperty, value);
316 NotifyPropertyChanged();
321 /// Starts the video playback.
323 /// <since_tizen> 3 </since_tizen>
326 Interop.VideoView.VideoView_Play(swigCPtr);
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
331 /// Pauses the video playback.
333 /// <since_tizen> 3 </since_tizen>
336 Interop.VideoView.VideoView_Pause(swigCPtr);
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 /// Stops the video playback.
343 /// <since_tizen> 3 </since_tizen>
346 Interop.VideoView.VideoView_Stop(swigCPtr);
347 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351 /// Seeks forward by the specified number of milliseconds.
353 /// <param name="millisecond">The position for forward playback.</param>
354 /// <since_tizen> 3 </since_tizen>
355 public void Forward(int millisecond)
357 Interop.VideoView.VideoView_Forward(swigCPtr, millisecond);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 /// Seeks backward by the specified number of milliseconds.
364 /// <param name="millisecond">The position for backward playback.</param>
365 /// <since_tizen> 3 </since_tizen>
366 public void Backward(int millisecond)
368 Interop.VideoView.VideoView_Backward(swigCPtr, millisecond);
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372 internal VideoViewSignal FinishedSignal()
374 VideoViewSignal ret = new VideoViewSignal(Interop.VideoView.VideoView_FinishedSignal(swigCPtr), false);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
381 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
387 /// <param name="type">DisposeTypes</param>
388 /// <since_tizen> 3 </since_tizen>
389 protected override void Dispose(DisposeTypes type)
396 //Release your own unmanaged resources here.
397 //You should not access any managed member here except static instance.
398 //because the execution order of Finalizes is non-deterministic.
400 if (this != null && _videoViewFinishedCallbackDelegate != null)
402 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
408 /// This will not be public opened.
409 [EditorBrowsable(EditorBrowsableState.Never)]
410 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
412 Interop.VideoView.delete_VideoView(swigCPtr);
415 // Callback for VideoView Finished signal
416 private void OnFinished(IntPtr data)
418 FinishedEventArgs e = new FinishedEventArgs();
420 // Populate all members of "e" (FinishedEventArgs) with real data
421 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
423 if (_videoViewFinishedEventHandler != null)
425 //here we send all data to user event handlers
426 _videoViewFinishedEventHandler(this, e);
431 /// Event arguments that passed via the finished signal.
433 /// <since_tizen> 3 </since_tizen>
434 public class FinishedEventArgs : EventArgs
436 private VideoView _videoView;
439 /// The view for video playback and display.
441 /// <since_tizen> 3 </since_tizen>
442 public VideoView VideoView
455 internal new class Property
457 internal static readonly int VIDEO = Interop.VideoView.VideoView_Property_VIDEO_get();
458 internal static readonly int LOOPING = Interop.VideoView.VideoView_Property_LOOPING_get();
459 internal static readonly int MUTED = Interop.VideoView.VideoView_Property_MUTED_get();
460 internal static readonly int VOLUME = Interop.VideoView.VideoView_Property_VOLUME_get();
461 internal static readonly int UNDERLAY = Interop.VideoView.VideoView_Property_UNDERLAY_get();