a5363ca4509a6b89c18a62bd7c9febd904b70a68
[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             // By default, we do not want the position to use the anchor point
45             PositionUsesAnchorPoint = false;
46         }
47
48         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
49         {
50             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
51         }
52
53         protected override void Dispose(DisposeTypes type)
54         {
55             if(disposed)
56             {
57                 return;
58             }
59
60             if(type == DisposeTypes.Explicit)
61             {
62                 //Called by User
63                 //Release your own managed resources here.
64                 //You should release all of your own disposable objects here.
65             }
66
67             //Release your own unmanaged resources here.
68             //You should not access any managed member here except static instance.
69             //because the execution order of Finalizes is non-deterministic.
70
71             if (swigCPtr.Handle != global::System.IntPtr.Zero)
72             {
73                 if (swigCMemOwn)
74                 {
75                     swigCMemOwn = false;
76                     NDalicPINVOKE.delete_VideoView(swigCPtr);
77                 }
78                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
79             }
80
81             base.Dispose(type);
82         }
83
84         /// <summary>
85         /// Event arguments that passed via Finished signal
86         /// </summary>
87         public class FinishedEventArgs : EventArgs
88         {
89             private VideoView _videoView;
90
91             /// <summary>
92             /// The view for video playback and display.
93             /// </summary>
94             public VideoView VideoView
95             {
96                 get
97                 {
98                     return _videoView;
99                 }
100                 set
101                 {
102                     _videoView = value;
103                 }
104             }
105         }
106
107
108         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
109         private delegate void FinishedCallbackDelegate(IntPtr data);
110         private EventHandler<FinishedEventArgs> _videoViewFinishedEventHandler;
111         private FinishedCallbackDelegate _videoViewFinishedCallbackDelegate;
112
113
114         /// <summary>
115         /// Event for Finished signal which can be used to subscribe/unsubscribe the event handler
116         /// (in the type of FinishedEventHandler-DaliEventHandler<object,FinishedEventArgs>) provided by the user.<br>
117         /// Finished signal is emitted when a video playback have finished.<br>
118         /// </summary>
119         public event EventHandler<FinishedEventArgs> Finished
120         {
121             add
122             {
123                 if (_videoViewFinishedEventHandler == null)
124                 {
125                     _videoViewFinishedCallbackDelegate = (OnFinished);
126                     FinishedSignal().Connect(_videoViewFinishedCallbackDelegate);
127                 }
128                 _videoViewFinishedEventHandler += value;
129             }
130             remove
131             {
132                 _videoViewFinishedEventHandler -= value;
133                 if (_videoViewFinishedEventHandler == null && FinishedSignal().Empty() == false)
134                 {
135                     FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
136                 }
137             }
138         }
139
140         // Callback for VideoView Finished signal
141         private void OnFinished(IntPtr data)
142         {
143             FinishedEventArgs e = new FinishedEventArgs();
144
145             // Populate all members of "e" (FinishedEventArgs) with real data
146             e.VideoView = Registry.GetManagedBaseHandleFromNativePtr(data) as VideoView;
147
148             if (_videoViewFinishedEventHandler != null)
149             {
150                 //here we send all data to user event handlers
151                 _videoViewFinishedEventHandler(this, e);
152             }
153         }
154
155         internal class Property
156         {
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         }
162
163         /// <summary>
164         /// Creates an initialized VideoView.
165         /// </summary>
166         public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
167         {
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169
170         }
171
172         /// <summary>
173         /// Creates an initialized VideoView.<br>
174         /// If the string is empty, VideoView will not display anything.<br>
175         /// </summary>
176         /// <param name="url">The url of the video resource to display</param>
177         public VideoView(string url) : this(NDalicPINVOKE.VideoView_New__SWIG_1(url), true)
178         {
179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180
181         }
182         internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
183         {
184             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185         }
186
187         /// <summary>
188         /// Starts the video playback.
189         /// </summary>
190         public void Play()
191         {
192             NDalicPINVOKE.VideoView_Play(swigCPtr);
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194         }
195
196         /// <summary>
197         /// Pauses the video playback.
198         /// </summary>
199         public void Pause()
200         {
201             NDalicPINVOKE.VideoView_Pause(swigCPtr);
202             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203         }
204
205         /// <summary>
206         /// Stops the video playback.
207         /// </summary>
208         public void Stop()
209         {
210             NDalicPINVOKE.VideoView_Stop(swigCPtr);
211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212         }
213
214         /// <summary>
215         /// Seeks forward by the specified number of milliseconds.
216         /// </summary>
217         /// <param name="millisecond">The position for forward playback</param>
218         public void Forward(int millisecond)
219         {
220             NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222         }
223
224         /// <summary>
225         /// Seeks backward by the specified number of milliseconds.
226         /// </summary>
227         /// <param name="millisecond">The position for backward playback</param>
228         public void Backward(int millisecond)
229         {
230             NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232         }
233
234         internal VideoViewSignal FinishedSignal()
235         {
236             VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238             return ret;
239         }
240
241         /// <summary>
242         /// video file url as string type or PropertyMap.
243         /// </summary>
244         public PropertyMap Video
245         {
246             get
247             {
248                 PropertyMap temp = new PropertyMap();
249                 GetProperty(VideoView.Property.VIDEO).Get(temp);
250                 return temp;
251             }
252             set
253             {
254                 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
255             }
256         }
257
258         /// <summary>
259         /// looping status, true or false.
260         /// </summary>
261         public bool Looping
262         {
263             get
264             {
265                 bool temp = false;
266                 GetProperty(VideoView.Property.LOOPING).Get(out temp);
267                 return temp;
268             }
269             set
270             {
271                 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
272             }
273         }
274
275         /// <summary>
276         /// mute status, true or false.
277         /// </summary>
278         public bool Muted
279         {
280             get
281             {
282                 bool temp = false;
283                 GetProperty(VideoView.Property.MUTED).Get(out temp);
284                 return temp;
285             }
286             set
287             {
288                 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
289             }
290         }
291
292         /// <summary>
293         /// left and right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
294         /// </summary>
295         public PropertyMap Volume
296         {
297             get
298             {
299                 PropertyMap temp = new PropertyMap();
300                 GetProperty(VideoView.Property.VOLUME).Get(temp);
301                 return temp;
302             }
303             set
304             {
305                 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
306             }
307         }
308
309     }
310
311 }