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