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();
156 internal VideoView(VideoView videoView) : this(Interop.VideoView.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.VideoView.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
165 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
166 private delegate void FinishedCallbackDelegate(IntPtr data);
169 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler
170 /// The finished signal is emitted when a video playback has finished.<br />
172 /// <since_tizen> 3 </since_tizen>
173 public event EventHandler<FinishedEventArgs> Finished
177 if (_videoViewFinishedEventHandler == null)
179 _videoViewFinishedCallbackDelegate = (OnFinished);
180 FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
182 _videoViewFinishedEventHandler += value;
186 _videoViewFinishedEventHandler -= value;
187 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
189 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
195 /// Video file setting type of PropertyMap.
197 /// <since_tizen> 3 </since_tizen>
198 public PropertyMap Video
202 return (PropertyMap)GetValue(VideoProperty);
206 SetValue(VideoProperty, value);
207 NotifyPropertyChanged();
212 /// The looping status, true or false.
214 /// <since_tizen> 3 </since_tizen>
219 return (bool)GetValue(LoopingProperty);
223 SetValue(LoopingProperty, value);
224 NotifyPropertyChanged();
229 /// The mute status, true or false.
231 /// <since_tizen> 3 </since_tizen>
236 return (bool)GetValue(MutedProperty);
240 SetValue(MutedProperty, value);
241 NotifyPropertyChanged();
246 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
248 /// <since_tizen> 3 </since_tizen>
249 public PropertyMap Volume
253 return (PropertyMap)GetValue(VolumeProperty);
257 SetValue(VolumeProperty, value);
258 NotifyPropertyChanged();
263 /// Video rendering by underlay, true or false.<br />
264 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
266 /// <since_tizen> 4 </since_tizen>
271 return (bool)GetValue(UnderlayProperty);
275 SetValue(UnderlayProperty, value);
276 NotifyPropertyChanged();
281 /// Video file URL as string type.
283 /// <since_tizen> 4 </since_tizen>
284 public string ResourceUrl
288 return (string)GetValue(ResourceUrlProperty);
292 SetValue(ResourceUrlProperty, value);
293 NotifyPropertyChanged();
298 /// Starts the video playback.
300 /// <since_tizen> 3 </since_tizen>
303 Interop.VideoView.VideoView_Play(swigCPtr);
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308 /// Pauses the video playback.
310 /// <since_tizen> 3 </since_tizen>
313 Interop.VideoView.VideoView_Pause(swigCPtr);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 /// Stops the video playback.
320 /// <since_tizen> 3 </since_tizen>
323 Interop.VideoView.VideoView_Stop(swigCPtr);
324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328 /// Seeks forward by the specified number of milliseconds.
330 /// <param name="millisecond">The position for forward playback.</param>
331 /// <since_tizen> 3 </since_tizen>
332 public void Forward(int millisecond)
334 Interop.VideoView.VideoView_Forward(swigCPtr, millisecond);
335 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 /// Seeks backward by the specified number of milliseconds.
341 /// <param name="millisecond">The position for backward playback.</param>
342 /// <since_tizen> 3 </since_tizen>
343 public void Backward(int millisecond)
345 Interop.VideoView.VideoView_Backward(swigCPtr, millisecond);
346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
349 internal VideoViewSignal FinishedSignal()
351 VideoViewSignal ret = new VideoViewSignal(Interop.VideoView.VideoView_FinishedSignal(swigCPtr), false);
352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
358 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
364 /// <param name="type">DisposeTypes</param>
365 /// <since_tizen> 3 </since_tizen>
366 protected override void Dispose(DisposeTypes type)
373 //Release your own unmanaged resources here.
374 //You should not access any managed member here except static instance.
375 //because the execution order of Finalizes is non-deterministic.
377 if (this != null && _videoViewFinishedCallbackDelegate != null)
379 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
385 /// This will not be public opened.
386 [EditorBrowsable(EditorBrowsableState.Never)]
387 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
389 Interop.VideoView.delete_VideoView(swigCPtr);
392 // Callback for VideoView Finished signal
393 private void OnFinished(IntPtr data)
395 FinishedEventArgs e = new FinishedEventArgs();
397 // Populate all members of "e" (FinishedEventArgs) with real data
398 e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
400 if (_videoViewFinishedEventHandler != null)
402 //here we send all data to user event handlers
403 _videoViewFinishedEventHandler(this, e);
408 /// Event arguments that passed via the finished signal.
410 /// <since_tizen> 3 </since_tizen>
411 public class FinishedEventArgs : EventArgs
413 private VideoView _videoView;
416 /// The view for video playback and display.
418 /// <since_tizen> 3 </since_tizen>
419 public VideoView VideoView
432 internal new class Property
434 internal static readonly int VIDEO = Interop.VideoView.VideoView_Property_VIDEO_get();
435 internal static readonly int LOOPING = Interop.VideoView.VideoView_Property_LOOPING_get();
436 internal static readonly int MUTED = Interop.VideoView.VideoView_Property_MUTED_get();
437 internal static readonly int VOLUME = Interop.VideoView.VideoView_Property_VOLUME_get();
438 internal static readonly int UNDERLAY = Interop.VideoView.VideoView_Property_UNDERLAY_get();