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 (this != null && _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 /// Starts the video playback.
193 /// <since_tizen> 3 </since_tizen>
196 NDalicPINVOKE.VideoView_Play(swigCPtr);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 /// Pauses the video playback.
203 /// <since_tizen> 3 </since_tizen>
206 NDalicPINVOKE.VideoView_Pause(swigCPtr);
207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211 /// Stops the video playback.
213 /// <since_tizen> 3 </since_tizen>
216 NDalicPINVOKE.VideoView_Stop(swigCPtr);
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221 /// Seeks forward by the specified number of milliseconds.
223 /// <param name="millisecond">The position for forward playback.</param>
224 /// <since_tizen> 3 </since_tizen>
225 public void Forward(int millisecond)
227 NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 /// Seeks backward by the specified number of milliseconds.
234 /// <param name="millisecond">The position for backward playback.</param>
235 /// <since_tizen> 3 </since_tizen>
236 public void Backward(int millisecond)
238 NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 internal VideoViewSignal FinishedSignal()
244 VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 /// Video file setting type of PropertyMap.
252 /// <since_tizen> 3 </since_tizen>
253 public PropertyMap Video
257 PropertyMap temp = new PropertyMap();
258 GetProperty(VideoView.Property.VIDEO).Get(temp);
263 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
264 NotifyPropertyChanged();
269 /// The looping status, true or false.
271 /// <since_tizen> 3 </since_tizen>
277 GetProperty(VideoView.Property.LOOPING).Get(out temp);
282 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
283 NotifyPropertyChanged();
288 /// The mute status, true or false.
290 /// <since_tizen> 3 </since_tizen>
296 GetProperty(VideoView.Property.MUTED).Get(out temp);
301 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
302 NotifyPropertyChanged();
307 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
309 /// <since_tizen> 3 </since_tizen>
310 public PropertyMap Volume
314 PropertyMap temp = new PropertyMap();
315 GetProperty(VideoView.Property.VOLUME).Get(temp);
320 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
321 NotifyPropertyChanged();
326 /// Video rendering by underlay, true or false.<br />
327 /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
329 /// <since_tizen> 4 </since_tizen>
335 GetProperty(VideoView.Property.UNDERLAY).Get(out temp);
340 SetProperty(VideoView.Property.UNDERLAY, new PropertyValue(value));
341 NotifyPropertyChanged();
346 /// Video file URL as string type.
348 /// <since_tizen> 4 </since_tizen>
349 public string ResourceUrl
354 GetProperty(VideoView.Property.VIDEO).Get(out tmp);
359 SetProperty(VideoView.Property.VIDEO, new PropertyValue(value));
360 NotifyPropertyChanged();