1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Video;
26 
27 private import gio.FileIF;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gtk.MediaStream;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * `GtkVideo` is a widget to show a `GtkMediaStream` with media controls.
39  * 
40  * ![An example GtkVideo](video.png)
41  * 
42  * The controls are available separately as [class@Gtk.MediaControls].
43  * If you just want to display a video without controls, you can treat it
44  * like any other paintable and for example put it into a [class@Gtk.Picture].
45  * 
46  * `GtkVideo` aims to cover use cases such as previews, embedded animations,
47  * etc. It supports autoplay, looping, and simple media controls. It does
48  * not have support for video overlays, multichannel audio, device
49  * selection, or input. If you are writing a full-fledged video player,
50  * you may want to use the [class@Gdk.Paintable] API and a media framework
51  * such as Gstreamer directly.
52  */
53 public class Video : Widget
54 {
55 	/** the main Gtk struct */
56 	protected GtkVideo* gtkVideo;
57 
58 	/** Get the main Gtk struct */
59 	public GtkVideo* getVideoStruct(bool transferOwnership = false)
60 	{
61 		if (transferOwnership)
62 			ownedRef = false;
63 		return gtkVideo;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)gtkVideo;
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkVideo* gtkVideo, bool ownedRef = false)
76 	{
77 		this.gtkVideo = gtkVideo;
78 		super(cast(GtkWidget*)gtkVideo, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gtk_video_get_type();
86 	}
87 
88 	/**
89 	 * Creates a new empty `GtkVideo`.
90 	 *
91 	 * Returns: a new `GtkVideo`
92 	 *
93 	 * Throws: ConstructionException GTK+ fails to create the object.
94 	 */
95 	public this()
96 	{
97 		auto __p = gtk_video_new();
98 
99 		if(__p is null)
100 		{
101 			throw new ConstructionException("null returned by new");
102 		}
103 
104 		this(cast(GtkVideo*) __p);
105 	}
106 
107 	/**
108 	 * Creates a `GtkVideo` to play back the given @file.
109 	 *
110 	 * Params:
111 	 *     file = a `GFile`
112 	 *
113 	 * Returns: a new `GtkVideo`
114 	 *
115 	 * Throws: ConstructionException GTK+ fails to create the object.
116 	 */
117 	public this(FileIF file)
118 	{
119 		auto __p = gtk_video_new_for_file((file is null) ? null : file.getFileStruct());
120 
121 		if(__p is null)
122 		{
123 			throw new ConstructionException("null returned by new_for_file");
124 		}
125 
126 		this(cast(GtkVideo*) __p);
127 	}
128 
129 	/**
130 	 * Creates a `GtkVideo` to play back the given @filename.
131 	 *
132 	 * This is a utility function that calls [ctor@Gtk.Video.new_for_file],
133 	 * See that function for details.
134 	 *
135 	 * Params:
136 	 *     filename = filename to play back
137 	 *
138 	 * Returns: a new `GtkVideo`
139 	 *
140 	 * Throws: ConstructionException GTK+ fails to create the object.
141 	 */
142 	public this(string filename)
143 	{
144 		auto __p = gtk_video_new_for_filename(Str.toStringz(filename));
145 
146 		if(__p is null)
147 		{
148 			throw new ConstructionException("null returned by new_for_filename");
149 		}
150 
151 		this(cast(GtkVideo*) __p);
152 	}
153 
154 	/**
155 	 * Creates a `GtkVideo` to play back the given @stream.
156 	 *
157 	 * Params:
158 	 *     stream = a `GtkMediaStream`
159 	 *
160 	 * Returns: a new `GtkVideo`
161 	 *
162 	 * Throws: ConstructionException GTK+ fails to create the object.
163 	 */
164 	public this(MediaStream stream)
165 	{
166 		auto __p = gtk_video_new_for_media_stream((stream is null) ? null : stream.getMediaStreamStruct());
167 
168 		if(__p is null)
169 		{
170 			throw new ConstructionException("null returned by new_for_media_stream");
171 		}
172 
173 		this(cast(GtkVideo*) __p);
174 	}
175 
176 	/**
177 	 * Returns %TRUE if videos have been set to loop.
178 	 *
179 	 * Returns: %TRUE if streams should autoplay
180 	 */
181 	public bool getAutoplay()
182 	{
183 		return gtk_video_get_autoplay(gtkVideo) != 0;
184 	}
185 
186 	/**
187 	 * Gets the file played by @self or %NULL if not playing back
188 	 * a file.
189 	 *
190 	 * Returns: The file played by @self
191 	 */
192 	public FileIF getFile()
193 	{
194 		auto __p = gtk_video_get_file(gtkVideo);
195 
196 		if(__p is null)
197 		{
198 			return null;
199 		}
200 
201 		return ObjectG.getDObject!(FileIF)(cast(GFile*) __p);
202 	}
203 
204 	/**
205 	 * Returns %TRUE if videos have been set to loop.
206 	 *
207 	 * Returns: %TRUE if streams should loop
208 	 */
209 	public bool getLoop()
210 	{
211 		return gtk_video_get_loop(gtkVideo) != 0;
212 	}
213 
214 	/**
215 	 * Gets the media stream managed by @self or %NULL if none.
216 	 *
217 	 * Returns: The media stream managed by @self
218 	 */
219 	public MediaStream getMediaStream()
220 	{
221 		auto __p = gtk_video_get_media_stream(gtkVideo);
222 
223 		if(__p is null)
224 		{
225 			return null;
226 		}
227 
228 		return ObjectG.getDObject!(MediaStream)(cast(GtkMediaStream*) __p);
229 	}
230 
231 	/**
232 	 * Sets whether @self automatically starts playback when it
233 	 * becomes visible or when a new file gets loaded.
234 	 *
235 	 * Params:
236 	 *     autoplay = whether media streams should autoplay
237 	 */
238 	public void setAutoplay(bool autoplay)
239 	{
240 		gtk_video_set_autoplay(gtkVideo, autoplay);
241 	}
242 
243 	/**
244 	 * Makes @self play the given @file.
245 	 *
246 	 * Params:
247 	 *     file = the file to play
248 	 */
249 	public void setFile(FileIF file)
250 	{
251 		gtk_video_set_file(gtkVideo, (file is null) ? null : file.getFileStruct());
252 	}
253 
254 	/**
255 	 * Makes @self play the given @filename.
256 	 *
257 	 * This is a utility function that calls gtk_video_set_file(),
258 	 *
259 	 * Params:
260 	 *     filename = the filename to play
261 	 */
262 	public void setFilename(string filename)
263 	{
264 		gtk_video_set_filename(gtkVideo, Str.toStringz(filename));
265 	}
266 
267 	/**
268 	 * Sets whether new files loaded by @self should be set to loop.
269 	 *
270 	 * Params:
271 	 *     loop = whether media streams should loop
272 	 */
273 	public void setLoop(bool loop)
274 	{
275 		gtk_video_set_loop(gtkVideo, loop);
276 	}
277 
278 	/**
279 	 * Sets the media stream to be played back.
280 	 *
281 	 * @self will take full control of managing the media stream. If you
282 	 * want to manage a media stream yourself, consider using a
283 	 * [class@Gtk.Picture] for display.
284 	 *
285 	 * If you want to display a file, consider using [method@Gtk.Video.set_file]
286 	 * instead.
287 	 *
288 	 * Params:
289 	 *     stream = The media stream to play or %NULL to unset
290 	 */
291 	public void setMediaStream(MediaStream stream)
292 	{
293 		gtk_video_set_media_stream(gtkVideo, (stream is null) ? null : stream.getMediaStreamStruct());
294 	}
295 
296 	/**
297 	 * Makes @self play the resource at the given @resource_path.
298 	 *
299 	 * This is a utility function that calls [method@Gtk.Video.set_file].
300 	 *
301 	 * Params:
302 	 *     resourcePath = the resource to set
303 	 */
304 	public void setResource(string resourcePath)
305 	{
306 		gtk_video_set_resource(gtkVideo, Str.toStringz(resourcePath));
307 	}
308 }