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();
163 /// Creates an initialized VideoView.
165 /// <since_tizen> 3 </since_tizen>
166 public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 /// Creates an initialized VideoView.<br />
174 /// If the string is empty, VideoView will not display anything.<br />
176 /// <param name="url">The URL of the video resource to display.</param>
177 /// <since_tizen> 3 </since_tizen>
178 public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 /// [Obsolete("Please do not use! this will be deprecated")]
191 /// <param name="handle"></param>
192 /// <returns></returns>
193 [Obsolete("Please do not use! this will be deprecated")]
194 public new static VideoView DownCast(BaseHandle handle)
196 VideoView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as VideoView;
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202 /// Starts the video playback.
204 /// <since_tizen> 3 </since_tizen>
207 NDalicPINVOKE.VideoView_Play(swigCPtr);
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 /// Pauses the video playback.
214 /// <since_tizen> 3 </since_tizen>
217 NDalicPINVOKE.VideoView_Pause(swigCPtr);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 /// Stops the video playback.
224 /// <since_tizen> 3 </since_tizen>
227 NDalicPINVOKE.VideoView_Stop(swigCPtr);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 /// Seeks forward by the specified number of milliseconds.
234 /// <param name="millisecond">The position for forward playback.</param>
235 /// <since_tizen> 3 </since_tizen>
236 public void Forward(int millisecond)
238 NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 /// Seeks backward by the specified number of milliseconds.
245 /// <param name="millisecond">The position for backward playback.</param>
246 /// <since_tizen> 3 </since_tizen>
247 public void Backward(int millisecond)
249 NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 internal VideoViewSignal FinishedSignal()
255 VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 /// Video file URL as string type or PropertyMap.
263 /// <since_tizen> 3 </since_tizen>
264 public PropertyMap Video
268 PropertyMap temp = new PropertyMap();
269 GetProperty(VideoView.Property.VIDEO).Get(temp);
274 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
279 /// The looping status, true or false.
281 /// <since_tizen> 3 </since_tizen>
287 GetProperty(VideoView.Property.LOOPING).Get(out temp);
292 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
297 /// The mute status, true or false.
299 /// <since_tizen> 3 </since_tizen>
305 GetProperty(VideoView.Property.MUTED).Get(out temp);
310 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
315 /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
317 /// <since_tizen> 3 </since_tizen>
318 public PropertyMap Volume
322 PropertyMap temp = new PropertyMap();
323 GetProperty(VideoView.Property.VOLUME).Get(temp);
328 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));