1 /** 2 Control for playing video streams. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.videoplayer; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.control; 24 import godot.videostream; 25 import godot.texture; 26 import godot.canvasitem; 27 import godot.node; 28 /** 29 Control for playing video streams. 30 31 Control node for playing video streams. Supported formats are WebM and OGV Theora. 32 */ 33 @GodotBaseClass struct VideoPlayer 34 { 35 enum string _GODOT_internal_name = "VideoPlayer"; 36 public: 37 @nogc nothrow: 38 union { godot_object _godot_object; Control _GODOT_base; } 39 alias _GODOT_base this; 40 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 41 package(godot) __gshared bool _classBindingInitialized = false; 42 package(godot) static struct _classBinding 43 { 44 __gshared: 45 @GodotName("set_stream") GodotMethod!(void, VideoStream) setStream; 46 @GodotName("get_stream") GodotMethod!(VideoStream) getStream; 47 @GodotName("play") GodotMethod!(void) play; 48 @GodotName("stop") GodotMethod!(void) stop; 49 @GodotName("is_playing") GodotMethod!(bool) isPlaying; 50 @GodotName("set_paused") GodotMethod!(void, bool) setPaused; 51 @GodotName("is_paused") GodotMethod!(bool) isPaused; 52 @GodotName("set_volume") GodotMethod!(void, double) setVolume; 53 @GodotName("get_volume") GodotMethod!(double) getVolume; 54 @GodotName("set_volume_db") GodotMethod!(void, double) setVolumeDb; 55 @GodotName("get_volume_db") GodotMethod!(double) getVolumeDb; 56 @GodotName("set_audio_track") GodotMethod!(void, long) setAudioTrack; 57 @GodotName("get_audio_track") GodotMethod!(long) getAudioTrack; 58 @GodotName("get_stream_name") GodotMethod!(String) getStreamName; 59 @GodotName("set_stream_position") GodotMethod!(void, double) setStreamPosition; 60 @GodotName("get_stream_position") GodotMethod!(double) getStreamPosition; 61 @GodotName("set_autoplay") GodotMethod!(void, bool) setAutoplay; 62 @GodotName("has_autoplay") GodotMethod!(bool) hasAutoplay; 63 @GodotName("set_expand") GodotMethod!(void, bool) setExpand; 64 @GodotName("has_expand") GodotMethod!(bool) hasExpand; 65 @GodotName("set_buffering_msec") GodotMethod!(void, long) setBufferingMsec; 66 @GodotName("get_buffering_msec") GodotMethod!(long) getBufferingMsec; 67 @GodotName("set_bus") GodotMethod!(void, String) setBus; 68 @GodotName("get_bus") GodotMethod!(String) getBus; 69 @GodotName("get_video_texture") GodotMethod!(Texture) getVideoTexture; 70 } 71 bool opEquals(in VideoPlayer other) const { return _godot_object.ptr is other._godot_object.ptr; } 72 VideoPlayer opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 73 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 74 mixin baseCasts; 75 static VideoPlayer _new() 76 { 77 static godot_class_constructor constructor; 78 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VideoPlayer"); 79 if(constructor is null) return typeof(this).init; 80 return cast(VideoPlayer)(constructor()); 81 } 82 @disable new(size_t s); 83 /** 84 85 */ 86 void setStream(VideoStream stream) 87 { 88 checkClassBinding!(typeof(this))(); 89 ptrcall!(void)(_classBinding.setStream, _godot_object, stream); 90 } 91 /** 92 93 */ 94 Ref!VideoStream getStream() const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(VideoStream)(_classBinding.getStream, _godot_object); 98 } 99 /** 100 Starts the video playback. 101 */ 102 void play() 103 { 104 checkClassBinding!(typeof(this))(); 105 ptrcall!(void)(_classBinding.play, _godot_object); 106 } 107 /** 108 Stops the video playback. 109 */ 110 void stop() 111 { 112 checkClassBinding!(typeof(this))(); 113 ptrcall!(void)(_classBinding.stop, _godot_object); 114 } 115 /** 116 Returns `true` if the video is playing. 117 */ 118 bool isPlaying() const 119 { 120 checkClassBinding!(typeof(this))(); 121 return ptrcall!(bool)(_classBinding.isPlaying, _godot_object); 122 } 123 /** 124 125 */ 126 void setPaused(in bool paused) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(_classBinding.setPaused, _godot_object, paused); 130 } 131 /** 132 133 */ 134 bool isPaused() const 135 { 136 checkClassBinding!(typeof(this))(); 137 return ptrcall!(bool)(_classBinding.isPaused, _godot_object); 138 } 139 /** 140 141 */ 142 void setVolume(in double volume) 143 { 144 checkClassBinding!(typeof(this))(); 145 ptrcall!(void)(_classBinding.setVolume, _godot_object, volume); 146 } 147 /** 148 149 */ 150 double getVolume() const 151 { 152 checkClassBinding!(typeof(this))(); 153 return ptrcall!(double)(_classBinding.getVolume, _godot_object); 154 } 155 /** 156 157 */ 158 void setVolumeDb(in double db) 159 { 160 checkClassBinding!(typeof(this))(); 161 ptrcall!(void)(_classBinding.setVolumeDb, _godot_object, db); 162 } 163 /** 164 165 */ 166 double getVolumeDb() const 167 { 168 checkClassBinding!(typeof(this))(); 169 return ptrcall!(double)(_classBinding.getVolumeDb, _godot_object); 170 } 171 /** 172 173 */ 174 void setAudioTrack(in long track) 175 { 176 checkClassBinding!(typeof(this))(); 177 ptrcall!(void)(_classBinding.setAudioTrack, _godot_object, track); 178 } 179 /** 180 181 */ 182 long getAudioTrack() const 183 { 184 checkClassBinding!(typeof(this))(); 185 return ptrcall!(long)(_classBinding.getAudioTrack, _godot_object); 186 } 187 /** 188 Returns the video stream's name. 189 */ 190 String getStreamName() const 191 { 192 checkClassBinding!(typeof(this))(); 193 return ptrcall!(String)(_classBinding.getStreamName, _godot_object); 194 } 195 /** 196 197 */ 198 void setStreamPosition(in double position) 199 { 200 checkClassBinding!(typeof(this))(); 201 ptrcall!(void)(_classBinding.setStreamPosition, _godot_object, position); 202 } 203 /** 204 205 */ 206 double getStreamPosition() const 207 { 208 checkClassBinding!(typeof(this))(); 209 return ptrcall!(double)(_classBinding.getStreamPosition, _godot_object); 210 } 211 /** 212 213 */ 214 void setAutoplay(in bool enabled) 215 { 216 checkClassBinding!(typeof(this))(); 217 ptrcall!(void)(_classBinding.setAutoplay, _godot_object, enabled); 218 } 219 /** 220 221 */ 222 bool hasAutoplay() const 223 { 224 checkClassBinding!(typeof(this))(); 225 return ptrcall!(bool)(_classBinding.hasAutoplay, _godot_object); 226 } 227 /** 228 229 */ 230 void setExpand(in bool enable) 231 { 232 checkClassBinding!(typeof(this))(); 233 ptrcall!(void)(_classBinding.setExpand, _godot_object, enable); 234 } 235 /** 236 237 */ 238 bool hasExpand() const 239 { 240 checkClassBinding!(typeof(this))(); 241 return ptrcall!(bool)(_classBinding.hasExpand, _godot_object); 242 } 243 /** 244 245 */ 246 void setBufferingMsec(in long msec) 247 { 248 checkClassBinding!(typeof(this))(); 249 ptrcall!(void)(_classBinding.setBufferingMsec, _godot_object, msec); 250 } 251 /** 252 253 */ 254 long getBufferingMsec() const 255 { 256 checkClassBinding!(typeof(this))(); 257 return ptrcall!(long)(_classBinding.getBufferingMsec, _godot_object); 258 } 259 /** 260 261 */ 262 void setBus(StringArg0)(in StringArg0 bus) 263 { 264 checkClassBinding!(typeof(this))(); 265 ptrcall!(void)(_classBinding.setBus, _godot_object, bus); 266 } 267 /** 268 269 */ 270 String getBus() const 271 { 272 checkClassBinding!(typeof(this))(); 273 return ptrcall!(String)(_classBinding.getBus, _godot_object); 274 } 275 /** 276 Returns the current frame as a $(D Texture). 277 */ 278 Ref!Texture getVideoTexture() 279 { 280 checkClassBinding!(typeof(this))(); 281 return ptrcall!(Texture)(_classBinding.getVideoTexture, _godot_object); 282 } 283 /** 284 The embedded audio track to play. 285 */ 286 @property long audioTrack() 287 { 288 return getAudioTrack(); 289 } 290 /// ditto 291 @property void audioTrack(long v) 292 { 293 setAudioTrack(v); 294 } 295 /** 296 297 */ 298 @property VideoStream stream() 299 { 300 return getStream(); 301 } 302 /// ditto 303 @property void stream(VideoStream v) 304 { 305 setStream(v); 306 } 307 /** 308 Audio volume in dB. 309 */ 310 @property double volumeDb() 311 { 312 return getVolumeDb(); 313 } 314 /// ditto 315 @property void volumeDb(double v) 316 { 317 setVolumeDb(v); 318 } 319 /** 320 Audio volume as a linear value. 321 */ 322 @property double volume() 323 { 324 return getVolume(); 325 } 326 /// ditto 327 @property void volume(double v) 328 { 329 setVolume(v); 330 } 331 /** 332 If `true` playback starts when the scene loads. Default value: `false`. 333 */ 334 @property bool autoplay() 335 { 336 return hasAutoplay(); 337 } 338 /// ditto 339 @property void autoplay(bool v) 340 { 341 setAutoplay(v); 342 } 343 /** 344 If `true` the video is paused. 345 */ 346 @property bool paused() 347 { 348 return isPaused(); 349 } 350 /// ditto 351 @property void paused(bool v) 352 { 353 setPaused(v); 354 } 355 /** 356 If `true` the video scales to the control size. Default value: `true`. 357 */ 358 @property bool expand() 359 { 360 return hasExpand(); 361 } 362 /// ditto 363 @property void expand(bool v) 364 { 365 setExpand(v); 366 } 367 /** 368 Amount of time in milliseconds to store in buffer while playing. 369 */ 370 @property long bufferingMsec() 371 { 372 return getBufferingMsec(); 373 } 374 /// ditto 375 @property void bufferingMsec(long v) 376 { 377 setBufferingMsec(v); 378 } 379 /** 380 The current position of the stream, in seconds. 381 */ 382 @property double streamPosition() 383 { 384 return getStreamPosition(); 385 } 386 /// ditto 387 @property void streamPosition(double v) 388 { 389 setStreamPosition(v); 390 } 391 /** 392 Audio bus to use for sound playback. 393 */ 394 @property String bus() 395 { 396 return getBus(); 397 } 398 /// ditto 399 @property void bus(String v) 400 { 401 setBus(v); 402 } 403 }