39d85ab1ec8679b65595b7510a0cddda760472f3
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / VideoView.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
18 // <auto-generated />
19 //
20 // This file was automatically generated by SWIG (http://www.swig.org).
21 // Version 3.0.9
22 //
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
26
27 namespace Tizen.NUI
28 {
29
30     using System;
31     using System.Runtime.InteropServices;
32     using Tizen.NUI.BaseComponents;
33     
34     /// <summary>
35     /// VideoView is a control for video playback and display.
36     /// </summary>
37     public class VideoView : View
38     {
39         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
40
41         internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
42         {
43             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
44         }
45
46         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
47         {
48             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
49         }
50
51         public override void Dispose()
52         {
53             if (!Window.IsInstalled())
54             {
55                 DisposeQueue.Instance.Add(this);
56                 return;
57             }
58
59             lock (this)
60             {
61                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62                 {
63                     if (swigCMemOwn)
64                     {
65                         swigCMemOwn = false;
66                         NDalicPINVOKE.delete_VideoView(swigCPtr);
67                     }
68                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
69                 }
70                 global::System.GC.SuppressFinalize(this);
71                 base.Dispose();
72             }
73         }
74
75         /// <summary>
76         /// Event arguments that passed via Finished signal
77         /// </summary>
78         public class FinishedEventArgs : EventArgs
79         {
80             private VideoView _videoView;
81
82             /// <summary>
83             /// The view for video playback and display.
84             /// </summary>
85             public VideoView VideoView
86             {
87                 get
88                 {
89                     return _videoView;
90                 }
91                 set
92                 {
93                     _videoView = value;
94                 }
95             }
96         }
97
98
99         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
100         private delegate void FinishedCallbackDelegate(IntPtr data);
101         private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
102         private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
103
104
105         /// <summary>
106         /// Event for Finished signal which can be used to subscribe/unsubscribe the event handler
107         /// (in the type of FinishedEventHandler-DaliEventHandler<object,FinishedEventArgs>) provided by the user.<br>
108         /// Finished signal is emitted when a video playback have finished.<br>
109         /// </summary>
110         public event EventHandler<FinishedEventArgs> Finished
111         {
112             add
113             {
114                 if (_videoViewFinishedEventHandler == null)
115                 {
116                     _videoViewFinishedCallbackDelegate = (OnFinished);
117                     FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
118                 }
119                 _videoViewFinishedEventHandler += value;
120             }
121             remove
122             {
123                 _videoViewFinishedEventHandler -= value;
124                 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
125                 {
126                     FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
127                 }
128             }
129         }
130
131         // Callback for VideoView Finished signal
132         private void OnFinished(IntPtr data)
133         {
134             FinishedEventArgs e = new FinishedEventArgs();
135
136             // Populate all members of "e" (FinishedEventArgs) with real data
137             e.VideoView = VideoView.GetVideoViewFromPtr(data);
138
139             if (_videoViewFinishedEventHandler != null)
140             {
141                 //here we send all data to user event handlers
142                 _videoViewFinishedEventHandler(this, e);
143             }
144         }
145
146         internal static VideoView GetVideoViewFromPtr(global::System.IntPtr cPtr)
147         {
148             VideoView ret = new VideoView(cPtr, false);
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150             return ret;
151         }
152
153
154         internal class Property : global::System.IDisposable
155         {
156             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
157             protected bool swigCMemOwn;
158
159             internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
160             {
161                 swigCMemOwn = cMemoryOwn;
162                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
163             }
164
165             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
166             {
167                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
168             }
169
170             ~Property()
171             {
172                 DisposeQueue.Instance.Add(this);
173             }
174
175             public virtual void Dispose()
176             {
177                 if (!Window.IsInstalled()) {
178                     DisposeQueue.Instance.Add(this);
179                     return;
180                 }
181
182                 lock (this)
183                 {
184                     if (swigCPtr.Handle != global::System.IntPtr.Zero)
185                     {
186                         if (swigCMemOwn)
187                         {
188                             swigCMemOwn = false;
189                             NDalicPINVOKE.delete_VideoView_Property(swigCPtr);
190                         }
191                         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
192                     }
193                     global::System.GC.SuppressFinalize(this);
194                 }
195             }
196
197             internal Property() : this(NDalicPINVOKE.new_VideoView_Property(), true)
198             {
199                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200             }
201
202             internal static readonly int VIDEO = NDalicPINVOKE.VideoView_Property_VIDEO_get();
203             internal static readonly int LOOPING = NDalicPINVOKE.VideoView_Property_LOOPING_get();
204             internal static readonly int MUTED = NDalicPINVOKE.VideoView_Property_MUTED_get();
205             internal static readonly int VOLUME = NDalicPINVOKE.VideoView_Property_VOLUME_get();
206
207         }
208
209         /// <summary>
210         /// Creates an initialized VideoView.
211         /// </summary>
212         public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
213         {
214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215
216         }
217
218         /// <summary>
219         /// Creates an initialized VideoView.<br>
220         /// If the string is empty, VideoView will not display anything.<br>
221         /// </summary>
222         /// <param name="url">The url of the video resource to display</param>
223         public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
224         {
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226
227         }
228         internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
229         {
230             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231         }
232
233         internal VideoView Assign(VideoView videoView)
234         {
235             VideoView ret = new VideoView(NDalicPINVOKE.VideoView_Assign(swigCPtr, VideoView.getCPtr(videoView)), false);
236             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237             return ret;
238         }
239
240         /// <summary>
241         /// Downcasts a handle to VideoView handle.<br>
242         /// If handle points to a VideoView, the downcast produces valid handle.<br>
243         /// If not, the returned handle is left uninitialized.<br>
244         /// </summary>
245         /// <param name="handle">Handle to an object</param>
246         /// <returns>Handle to a VideoView or an uninitialized handle</returns>
247         public new static VideoView DownCast(BaseHandle handle)
248         {
249             VideoView ret = new VideoView(NDalicPINVOKE.VideoView_DownCast(BaseHandle.getCPtr(handle)), true);
250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251             return ret;
252         }
253
254         /// <summary>
255         /// Starts the video playback.
256         /// </summary>
257         public void Play()
258         {
259             NDalicPINVOKE.VideoView_Play(swigCPtr);
260             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261         }
262
263         /// <summary>
264         /// Pauses the video playback.
265         /// </summary>
266         public void Pause()
267         {
268             NDalicPINVOKE.VideoView_Pause(swigCPtr);
269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270         }
271
272         /// <summary>
273         /// Stops the video playback.
274         /// </summary>
275         public void Stop()
276         {
277             NDalicPINVOKE.VideoView_Stop(swigCPtr);
278             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279         }
280
281         /// <summary>
282         /// Seeks forward by the specified number of milliseconds.
283         /// </summary>
284         /// <param name="millisecond">The position for forward playback</param>
285         public void Forward(int millisecond)
286         {
287             NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
288             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289         }
290
291         /// <summary>
292         /// Seeks backward by the specified number of milliseconds.
293         /// </summary>
294         /// <param name="millisecond">The position for backward playback</param>
295         public void Backward(int millisecond)
296         {
297             NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
298             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299         }
300
301         internal VideoViewSignal FinishedSignal()
302         {
303             VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
304             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305             return ret;
306         }
307
308         internal enum PropertyRange
309         {
310             PROPERTY_START_INDEX = PropertyRanges.PROPERTY_REGISTRATION_START_INDEX
311         }
312
313         /// <summary>
314         /// video file url as string type or PropertyMap.
315         /// </summary>
316         public PropertyMap Video
317         {
318             get
319             {
320                 PropertyMap temp = new PropertyMap();
321                 GetProperty(VideoView.Property.VIDEO).Get(temp);
322                 return temp;
323             }
324             set
325             {
326                 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
327             }
328         }
329
330         /// <summary>
331         /// looping status, true or false.
332         /// </summary>
333         public bool Looping
334         {
335             get
336             {
337                 bool temp = false;
338                 GetProperty(VideoView.Property.LOOPING).Get(ref temp);
339                 return temp;
340             }
341             set
342             {
343                 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
344             }
345         }
346
347         /// <summary>
348         /// mute status, true or false.
349         /// </summary>
350         public bool Muted
351         {
352             get
353             {
354                 bool temp = false;
355                 GetProperty(VideoView.Property.MUTED).Get(ref temp);
356                 return temp;
357             }
358             set
359             {
360                 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
361             }
362         }
363
364         /// <summary>
365         /// left and right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
366         /// </summary>
367         public PropertyMap Volume
368         {
369             get
370             {
371                 PropertyMap temp = new PropertyMap();
372                 GetProperty(VideoView.Property.VOLUME).Get(temp);
373                 return temp;
374             }
375             set
376             {
377                 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
378             }
379         }
380
381     }
382
383 }