[NUI] Add Obsolete attributes for EditorBrowsable apis
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / VideoView.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using System.Runtime.InteropServices;
20
21 namespace Tizen.NUI.BaseComponents
22 {
23     /// <summary>
24     /// VideoView is a control for video playback and display.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public class VideoView : View
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30
31         internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
32         {
33             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34         }
35
36         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VideoView obj)
37         {
38             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39         }
40
41         /// <summary>
42         /// Dispose.
43         /// </summary>
44         /// <param name="type">DisposeTypes</param>
45         /// <since_tizen> 3 </since_tizen>
46         protected override void Dispose(DisposeTypes type)
47         {
48             if(disposed)
49             {
50                 return;
51             }
52
53             if(type == DisposeTypes.Explicit)
54             {
55                 //Called by User
56                 //Release your own managed resources here.
57                 //You should release all of your own disposable objects here.
58             }
59
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.
63
64             if (_videoViewFinishedCallbackDelegate != null)
65             {
66                 FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
67             }
68
69             if (swigCPtr.Handle != global::System.IntPtr.Zero)
70             {
71                 if (swigCMemOwn)
72                 {
73                     swigCMemOwn = false;
74                     NDalicPINVOKE.delete_VideoView(swigCPtr);
75                 }
76                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
77             }
78
79             base.Dispose(type);
80         }
81
82         /// <summary>
83         /// Event arguments that passed via the finished signal.
84         /// </summary>
85         /// <since_tizen> 3 </since_tizen>
86         public class FinishedEventArgs : EventArgs
87         {
88             private VideoView _videoView;
89
90             /// <summary>
91             /// The view for video playback and display.
92             /// </summary>
93             /// <since_tizen> 3 </since_tizen>
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 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 />
117         /// </summary>
118         /// <since_tizen> 3 </since_tizen>
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 new 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             internal static readonly int UNDERLAY = NDalicPINVOKE.VideoView_Property_UNDERLAY_get();
162         }
163
164         /// <summary>
165         /// Creates an initialized VideoView.
166         /// </summary>
167         /// <since_tizen> 3 </since_tizen>
168         public VideoView() : this(NDalicPINVOKE.VideoView_New__SWIG_0(), true)
169         {
170             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171
172         }
173
174         /// <summary>
175         /// Creates an initialized VideoView.<br />
176         /// If the string is empty, VideoView will not display anything.<br />
177         /// </summary>
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)
181         {
182             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183
184         }
185         internal VideoView(VideoView videoView) : this(NDalicPINVOKE.new_VideoView__SWIG_1(VideoView.getCPtr(videoView)), true)
186         {
187             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188         }
189
190         /// <summary>
191         /// Downcasts a handle to videoView handle.
192         /// </summary>
193         /// <param name="handle"></param>
194         /// <returns></returns>
195         /// Please do not use! this will be deprecated!
196         /// Instead please use as keyword.
197         /// <since_tizen> 3 </since_tizen>
198         [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead!")]
199         [EditorBrowsable(EditorBrowsableState.Never)]
200         public new static VideoView DownCast(BaseHandle handle)
201         {
202             VideoView ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as VideoView;
203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204             return ret;
205         }
206
207         /// <summary>
208         /// Starts the video playback.
209         /// </summary>
210         /// <since_tizen> 3 </since_tizen>
211         public void Play()
212         {
213             NDalicPINVOKE.VideoView_Play(swigCPtr);
214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215         }
216
217         /// <summary>
218         /// Pauses the video playback.
219         /// </summary>
220         /// <since_tizen> 3 </since_tizen>
221         public void Pause()
222         {
223             NDalicPINVOKE.VideoView_Pause(swigCPtr);
224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225         }
226
227         /// <summary>
228         /// Stops the video playback.
229         /// </summary>
230         /// <since_tizen> 3 </since_tizen>
231         public void Stop()
232         {
233             NDalicPINVOKE.VideoView_Stop(swigCPtr);
234             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235         }
236
237         /// <summary>
238         /// Seeks forward by the specified number of milliseconds.
239         /// </summary>
240         /// <param name="millisecond">The position for forward playback.</param>
241         /// <since_tizen> 3 </since_tizen>
242         public void Forward(int millisecond)
243         {
244             NDalicPINVOKE.VideoView_Forward(swigCPtr, millisecond);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246         }
247
248         /// <summary>
249         /// Seeks backward by the specified number of milliseconds.
250         /// </summary>
251         /// <param name="millisecond">The position for backward playback.</param>
252         /// <since_tizen> 3 </since_tizen>
253         public void Backward(int millisecond)
254         {
255             NDalicPINVOKE.VideoView_Backward(swigCPtr, millisecond);
256             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257         }
258
259         internal VideoViewSignal FinishedSignal()
260         {
261             VideoViewSignal ret = new VideoViewSignal(NDalicPINVOKE.VideoView_FinishedSignal(swigCPtr), false);
262             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263             return ret;
264         }
265
266         /// <summary>
267         /// Video file setting type of PropertyMap.
268         /// </summary>
269         /// <since_tizen> 3 </since_tizen>
270         public PropertyMap Video
271         {
272             get
273             {
274                 PropertyMap temp = new PropertyMap();
275                 GetProperty(VideoView.Property.VIDEO).Get(temp);
276                 return temp;
277             }
278             set
279             {
280                 SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
281             }
282         }
283
284         /// <summary>
285         /// The looping status, true or false.
286         /// </summary>
287         /// <since_tizen> 3 </since_tizen>
288         public bool Looping
289         {
290             get
291             {
292                 bool temp = false;
293                 GetProperty(VideoView.Property.LOOPING).Get(out temp);
294                 return temp;
295             }
296             set
297             {
298                 SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
299             }
300         }
301
302         /// <summary>
303         /// The mute status, true or false.
304         /// </summary>
305         /// <since_tizen> 3 </since_tizen>
306         public bool Muted
307         {
308             get
309             {
310                 bool temp = false;
311                 GetProperty(VideoView.Property.MUTED).Get(out temp);
312                 return temp;
313             }
314             set
315             {
316                 SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
317             }
318         }
319
320         /// <summary>
321         /// The left and the right volume scalar as float type, PropertyMap with two values ( "left" and "right" ).
322         /// </summary>
323         /// <since_tizen> 3 </since_tizen>
324         public PropertyMap Volume
325         {
326             get
327             {
328                 PropertyMap temp = new PropertyMap();
329                 GetProperty(VideoView.Property.VOLUME).Get(temp);
330                 return temp;
331             }
332             set
333             {
334                 SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
335             }
336         }
337
338         /// <summary>
339         /// Video rendering by underlay, true or false.<br />
340         /// This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view.
341         /// </summary>
342         /// <since_tizen> 4 </since_tizen>
343         public bool Underlay
344         {
345             get
346             {
347                 bool temp = false;
348                 GetProperty(VideoView.Property.UNDERLAY).Get(out temp);
349                 return temp;
350             }
351             set
352             {
353                 SetProperty(VideoView.Property.UNDERLAY, new PropertyValue(value));
354             }
355         }
356
357         /// <summary>
358         /// Video file URL as string type.
359         /// </summary>
360         /// <since_tizen> 4 </since_tizen>
361         public string ResourceUrl
362         {
363             get
364             {
365                 string tmp;
366                 GetProperty(VideoView.Property.VIDEO).Get(out tmp);
367                 return tmp;
368             }
369             set
370             {
371                 SetProperty(VideoView.Property.VIDEO, new PropertyValue(value));
372             }
373         }
374
375     }
376
377 }