plyr 0.0.4

Rust bindings for plyr
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
#[cfg(feature = "options")]
use crate::options::{PlyrOptions, PreviewThumbnailsOptions};

#[cfg(feature = "options")]
use crate::source::SourceInfo;

use crate::{MediaType, Provider};

use js_sys::{Function, Object};
use wasm_bindgen::{prelude::*, JsCast};
use web_sys::{CustomEvent, HtmlButtonElement, HtmlElement, NodeList};

#[cfg_attr(feature = "cdn", wasm_bindgen(module = "/dist_cdn/main.js"))]
#[cfg_attr(not(feature = "cdn"), wasm_bindgen(module = "/dist/main.js"))]
extern "C" {
    // -------------------------------------------------------------------------------------------------
    // Plyr
    #[derive(Debug, Clone)]
    #[doc = "The Plyr class"]
    pub type Plyr;

    // constructor and static method
    #[wasm_bindgen(constructor)]
    #[doc = "Plyr constructor with css selector"]
    pub fn new(css_selector: &str) -> Plyr;

    #[wasm_bindgen(constructor)]
    #[doc = "Plyr constructor with options(jsvalue)"]
    pub fn new_with_options_jsvalue(css_selector: &str, options: &JsValue) -> Plyr;

    #[wasm_bindgen(constructor)]
    #[doc = "Plyr constructor with html element"]
    pub fn new_with_html_element(html_element: &HtmlElement) -> Plyr;

    #[wasm_bindgen(constructor)]
    #[doc = "Plyr constructor with html element and options(jsvalue)"]
    pub fn new_with_html_element_and_options_jsvalue(
        html_element: &HtmlElement,
        options: &JsValue,
    ) -> Plyr;

    #[wasm_bindgen(static_method_of=Plyr)]
    #[doc = "Plyr.setup with css selector"]
    pub fn setup(css_selector: &str) -> Vec<Plyr>;

    #[wasm_bindgen(static_method_of=Plyr, js_name="setup")]
    #[doc = "Plyr.setup with css selector and options(jsvalue)"]
    pub fn setup_with_options_jsvalue(css_selector: &str, options: &JsValue) -> Vec<Plyr>;

    #[wasm_bindgen(static_method_of=Plyr, js_name="setup")]
    #[doc = "Plyr.setup with html_elements"]
    pub fn setup_with_html_elements(html_elements: Vec<HtmlElement>) -> Vec<Plyr>;

    #[wasm_bindgen(static_method_of=Plyr, js_name="setup")]
    #[doc = "Plyr.setup with html_elements and options(jsvalue)"]
    pub fn setup_with_html_elements_and_options_jsvalue(
        html_elements: Vec<HtmlElement>,
        options: &JsValue,
    ) -> Vec<Plyr>;

    #[wasm_bindgen(static_method_of=Plyr, js_name="setup")]
    #[doc = "Plyr.setup with node_list"]
    pub fn setup_with_node_list(node_list: &NodeList) -> Vec<Plyr>;

    #[wasm_bindgen(static_method_of=Plyr, js_name="setup")]
    #[doc = "Plyr.setup with node_list and options(jsvalue)"]
    pub fn setup_with_node_list_and_options_jsvalue(
        node_list: &NodeList,
        options: &JsValue,
    ) -> Vec<Plyr>;

    #[wasm_bindgen(static_method_of=Plyr)]
    #[doc = "Plyr.supported with no arguments"]
    pub fn supported() -> Support;

    #[wasm_bindgen(static_method_of=Plyr)]
    #[doc = "Plyr.supported with media_type(jsvalue) and provider(jsvalue) and plays_inline"]
    pub fn supported_with_info_str(media_type: &str, provider: &str, plays_inline: bool)
        -> Support;

    // getter and setter

    #[wasm_bindgen(method, getter = isHTML5)]
    #[doc = "Getter for the `isHTML5` field of this class."]
    pub fn is_html5(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter = isEmbed)]
    #[doc = "Getter for the `isEmbed` field of this class."]
    pub fn is_embed(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `playing` field of this class."]
    pub fn playing(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `paused` field of this class."]
    pub fn paused(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `stopped` field of this class."]
    pub fn stopped(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `ended` field of this class."]
    pub fn ended(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `buffered` field of this class."]
    pub fn buffered(this: &Plyr) -> f32;

    #[wasm_bindgen(method, getter = currentTime)]
    #[doc = "Getter for the `currentTime` field of this class."]
    pub fn current_time(this: &Plyr) -> f32;

    #[wasm_bindgen(method, setter = currentTime)]
    #[doc = "Setter for the `currentTime` field of this class."]
    pub fn set_current_time(this: &Plyr, value: f32);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `seeking` field of this class."]
    pub fn seeking(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `duration` field of this class."]
    pub fn duration(this: &Plyr) -> f32;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `volume` field of this class."]
    pub fn volume(this: &Plyr) -> f32;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `volume` field of this class."]
    pub fn set_volume(this: &Plyr, value: f32);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `muted` field of this class."]
    pub fn muted(this: &Plyr) -> bool;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `muted` field of this class."]
    pub fn set_muted(this: &Plyr, value: bool);

    #[wasm_bindgen(method, getter = hasAudio)]
    #[doc = "Getter for the `hasAudio` field of this class."]
    pub fn has_audio(this: &Plyr) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `speed` field of this class."]
    pub fn speed(this: &Plyr) -> f32;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `speed` field of this class."]
    pub fn set_speed(this: &Plyr, value: f32);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `quality` field of this class."]
    pub fn quality(this: &Plyr) -> u32;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `quality` field of this class."]
    pub fn set_quality(this: &Plyr, value: u32);

    #[wasm_bindgen(method, getter = loop)]
    #[doc = "Getter for the `loop` field of this class."]
    pub fn loop_(this: &Plyr) -> bool;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `loop` field of this class."]
    pub fn set_loop(this: &Plyr, value: bool);

    #[wasm_bindgen(method, getter = source)]
    #[doc = "Getter for the `source` field of this class as JsValue."]
    pub fn source_jsvalue(this: &Plyr) -> JsValue;

    #[wasm_bindgen(method, setter = source)]
    #[doc = "Setter for the `seeking` field of this class with JsValue."]
    pub fn set_source_jsvalue(this: &Plyr, source: &JsValue);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `poster` field of this class."]
    pub fn poster(this: &Plyr) -> String;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `poster` field of this class."]
    pub fn set_poster(this: &Plyr, value: &str);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `autoplay` field of this class."]
    pub fn autoplay(this: &Plyr) -> bool;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `autoplay` field of this class."]
    pub fn set_autoplay(this: &Plyr, value: bool);

    #[wasm_bindgen(method, getter = currentTrack)]
    #[doc = "Getter for the `currentTrac` field of this class."]
    pub fn current_track(this: &Plyr) -> usize;

    #[wasm_bindgen(method, setter = currentTrack)]
    #[doc = "Setter for the `currentTrack` field of this class."]
    pub fn set_current_track(this: &Plyr, value: usize);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `language` field of this class."]
    pub fn language(this: &Plyr) -> String;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `language` field of this class."]
    pub fn set_language(this: &Plyr, value: &str);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `pip` field of this class."]
    pub fn pip(this: &Plyr) -> bool;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `pip` field of this class."]
    pub fn set_pip(this: &Plyr, value: bool);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `ratio` field of this class as Result of JsValue."]
    pub fn ratio(this: &Plyr) -> Result<String, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `ratio` field of this class."]
    pub fn set_ratio(this: &Plyr, value: String);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `elements` field of this class."]
    pub fn elements(this: &Plyr) -> Elements;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `elements` field of this class."]
    pub fn set_elements(this: &Plyr, elements: &Elements);

    #[wasm_bindgen(method, getter=provider)]
    #[doc = "Getter for the `provider` field of this class as String."]
    fn provider_string(this: &Plyr) -> String;

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `seeking` field of this class as Result of JsValue."]
    pub fn embed(this: &Plyr) -> Result<JsValue, JsValue>;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `fullscreen` field of this class as FullscreenControl type."]
    pub fn fullscreen(this: &Plyr) -> FullscreenControl;

    // method

    #[wasm_bindgen(method)]
    #[doc = "The `play` method."]
    pub fn play(this: &Plyr);

    #[cfg(feature = "future")]
    #[wasm_bindgen(method, js_name = "play")]
    #[doc = "The `play` method that returns Promise. *This API requires the following crate features to be activated: `html5`*"]
    pub async fn play_async(this: &Plyr);

    #[wasm_bindgen(method)]
    #[doc = "The `pause` method."]
    pub fn pause(this: &Plyr);

    #[wasm_bindgen(method, js_name = "togglePlay")]
    #[doc = "The `togglePlay` method."]
    pub fn toggle_play(this: &Plyr);

    #[wasm_bindgen(method, js_name = "togglePlay")]
    #[doc = "The `togglePlay` method with toggle bool."]
    pub fn toggle_play_with_toggle(this: &Plyr, toggle: bool);

    #[wasm_bindgen(method)]
    #[doc = "The `stop` method."]
    pub fn stop(this: &Plyr);

    #[wasm_bindgen(method)]
    #[doc = "The `restart` method."]
    pub fn restart(this: &Plyr);

    #[wasm_bindgen(method, js_name = "rewind")]
    #[doc = "The `rewind` method with seek time."]
    pub fn rewind_with_seek_time(this: &Plyr, seek_time: u32);

    #[wasm_bindgen(method)]
    #[doc = "The `rewind` method."]
    pub fn rewind(this: &Plyr);

    #[wasm_bindgen(method)]
    #[doc = "The `forward` method."]
    pub fn forward(this: &Plyr);

    #[wasm_bindgen(method, js_name = "forward")]
    #[doc = "The `forward` method with seek time."]
    pub fn forward_with_seek_time(this: &Plyr, seek_time: u32);

    #[wasm_bindgen(method, js_name = "increaseVolume")]
    #[doc = "The `increaseVolume` method."]
    pub fn increase_volume(this: &Plyr);

    #[wasm_bindgen(method, js_name = "increaseVolume")]
    #[doc = "The `increaseVolume` method with step."]
    pub fn increase_volume_with_step(this: &Plyr, step: u32);

    #[wasm_bindgen(method, js_name = "decreaseVolume")]
    #[doc = "The `decreaseVolume` method."]
    pub fn decrease_volume(this: &Plyr);

    #[wasm_bindgen(method, js_name = "decreaseVolume")]
    #[doc = "The `decreaseVolume` method with step."]
    pub fn decrease_volume_with_step(this: &Plyr, step: u32);

    #[wasm_bindgen(method, js_name = "toggleCaptions")]
    #[doc = "The `toggleCaptions` method."]
    pub fn toggle_captions(this: &Plyr);

    #[wasm_bindgen(method, js_name = "toggleCaptions")]
    #[doc = "The `toggleCaptions` method with toggle bool."]
    pub fn toggle_captions_with_toggle(this: &Plyr, toggle: bool);

    #[wasm_bindgen(method)]
    #[doc = "The `airplay` method."]
    pub fn airplay(this: &Plyr);

    #[wasm_bindgen(method, js_name = "setPreviewThumbnails")]
    #[doc = "The `setPreviewThumbnails` method with source(JsValue)."]
    pub fn set_preview_thumbnails_jsvalue(this: &Plyr, source: &JsValue);

    #[wasm_bindgen(method, js_name = "toggleControls")]
    #[doc = "The `toggleControls` method."]
    pub fn toggle_controls(this: &Plyr, toggle: bool);

    #[wasm_bindgen(method)]
    #[doc = "The `on` method."]
    pub fn on(this: &Plyr, event: &str, callback: &Function);

    #[wasm_bindgen(method)]
    #[doc = "The `once` method."]
    pub fn once(this: &Plyr, event: &str, callback: &Function);

    #[wasm_bindgen(method)]
    #[doc = "The `off` method."]
    pub fn off(this: &Plyr, event: &str, callback: &Function);

    #[wasm_bindgen(method)]
    #[doc = "The `supports` method."]
    pub fn supports(this: &Plyr, supports_type: &str) -> bool;

    #[wasm_bindgen(method)]
    #[doc = "The `destroy` method."]
    pub fn destroy(this: &Plyr);

    #[wasm_bindgen(method, js_name = "destroy")]
    #[doc = "The `destroy` method with callback(`js_sys::Function`)."]
    pub fn destroy_with_callback(this: &Plyr, callback: &Function);

    #[wasm_bindgen(method, js_name = "destroy")]
    #[doc = "The `destroy` method with soft."]
    pub fn destroy_with_soft(this: &Plyr, soft: bool);

    #[wasm_bindgen(method, js_name = "destroy")]
    #[doc = "The `destroy` method with callback(`js_sys::Function`) and soft."]
    pub fn destroy_with_callback_and_soft(this: &Plyr, callback: &Function, soft: bool);

    // -------------------------------------------------------------------------------------------------
    // Support

    #[derive(Debug, Clone)]
    #[doc = "Plyr.Support"]
    pub type Support;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `api` field of this object."]
    pub fn api(this: &Support) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `ui` field of this object."]
    pub fn ui(this: &Support) -> bool;

    // -------------------------------------------------------------------------------------------------
    // Elements

    #[derive(Debug, Clone)]
    #[doc = "Plyr.Elements.buttons object"]
    pub type Buttons;

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `airplay` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn airplay(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `airplay` field of this object."]
    pub fn set_airplay(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `captions` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn captions(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `captions` field of this object."]
    pub fn set_captions(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `download` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn download(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `download` field of this object."]
    pub fn set_download(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter = fastForward, catch)]
    #[doc = "Getter for the `fast_forward` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn fast_forward(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter = fastForward)]
    #[doc = "Setter for the `fast_forward` field of this object."]
    pub fn set_fast_forward(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `fullscreen` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn fullscreen(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `fullscreen` field of this object."]
    pub fn set_fullscreen(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `mute` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn mute(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `mute` field of this object."]
    pub fn set_mute(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `pip` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn pip(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `pip` field of this object."]
    pub fn set_pip(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `play` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn play(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter = play)]
    #[doc = "Setter for the `play` field of this object."]
    pub fn set_play(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter = play, catch)]
    #[doc = "Getter for the `play` field of this object as Vec<HtmlElement>. If it failed, this method returns Err() of JsValue"]
    pub fn play_multi(this: &Buttons) -> Result<Vec<HtmlButtonElement>, JsValue>;

    #[wasm_bindgen(method, setter = play)]
    #[doc = "Setter for the `play` field of this object with Vec<HtmlElement>."]
    pub fn set_play_multi(this: &Buttons, buttons: Vec<HtmlButtonElement>);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `restart` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn restart(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `restart` field of this object."]
    pub fn set_restart(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `rewind` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn rewind(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `rewind` field of this object."]
    pub fn set_rewind(this: &Buttons, button: HtmlButtonElement);

    #[wasm_bindgen(method, getter, catch)]
    #[doc = "Getter for the `settings` field of this object. If it failed, this method returns Err() of JsValue"]
    pub fn settings(this: &Buttons) -> Result<HtmlButtonElement, JsValue>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `settings` field of this object."]
    pub fn set_settings(this: &Buttons, button: HtmlButtonElement);

    #[derive(Debug, Clone)]
    #[doc = "Plyr.Elements object"]
    pub type Elements;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `buttons` field of this object."]
    pub fn buttons(this: &Elements) -> Buttons;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `buttons` field of this object."]
    pub fn set_buttons(this: &Elements, buttons: &Buttons);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `captions` field of this object."]
    pub fn captions(this: &Elements) -> Option<HtmlElement>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `captions` field of this object."]
    pub fn set_captions(this: &Elements, element: HtmlElement);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `container` field of this object."]
    pub fn container(this: &Elements) -> Option<HtmlElement>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `container` field of this object."]
    pub fn set_container(this: &Elements, element: HtmlElement);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `controls` field of this object."]
    pub fn controls(this: &Elements) -> Option<HtmlElement>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `controls` field of this object."]
    pub fn set_controls(this: &Elements, element: HtmlElement);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `fullscreen` field of this object."]
    pub fn fullscreen(this: &Elements) -> Option<HtmlElement>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `fullscreen` field of this object."]
    pub fn set_fullscreen(this: &Elements, element: HtmlElement);

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `wrapper` field of this object."]
    pub fn wrapper(this: &Elements) -> Option<HtmlElement>;

    #[wasm_bindgen(method, setter)]
    #[doc = "Setter for the `wrapper` field of this object."]
    pub fn set_wrapper(this: &Elements, element: HtmlElement);

    // -------------------------------------------------------------------------------------------------
    // Fullscreen

    #[derive(Debug, Clone)]
    #[doc = "Plyr.FullscreenControl object"]
    pub type FullscreenControl;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `active` field of this object."]
    pub fn active(this: &FullscreenControl) -> bool;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `enabled` field of this object."]
    pub fn enabled(this: &FullscreenControl) -> bool;

    #[wasm_bindgen(method)]
    #[doc = "The `enter` method of this object."]
    pub fn enter(this: &FullscreenControl);

    #[wasm_bindgen(method)]
    #[doc = "The `exit` method of this object."]
    pub fn exit(this: &FullscreenControl);

    #[wasm_bindgen(method)]
    #[doc = "The `toggle` method of this object."]
    pub fn toggle(this: &FullscreenControl);

    // -------------------------------------------------------------------------------------------------
    // PlyrEvent

    #[derive(Debug, Clone)]
    #[doc = "Type of Plyr.PlyrEvent.detail object"]
    pub type PlyrEventDetail;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `plyr` field of this object."]
    pub fn plyr(this: &PlyrEventDetail) -> Plyr;

    #[wasm_bindgen(extends = CustomEvent)]
    #[derive(Debug, Clone)]
    #[doc = "Plyr.PlyrEvent object"]
    pub type PlyrEvent;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `detail` field of this object."]
    pub fn detail(this: &PlyrEvent) -> PlyrEventDetail;

    // -------------------------------------------------------------------------------------------------
    // PlyrStateChangeEvent

    #[derive(Debug, Clone)]
    #[doc = "Type of Plyr.PlyrStateChangeEvent.detail object"]
    pub type PlyrStateChangeEventDetail;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `plyr` field of this object."]
    pub fn plyr(this: &PlyrStateChangeEventDetail) -> Plyr;

    #[wasm_bindgen(method, getter=code)]
    #[doc = "Getter for the `code` field of this object as i8."]
    fn code_int(this: &PlyrStateChangeEventDetail) -> i8;

    #[wasm_bindgen(extends = CustomEvent)]
    #[derive(Debug, Clone)]
    #[doc = "Plyr.PlyrStateChangeEvent object"]
    pub type PlyrStateChangeEvent;

    #[wasm_bindgen(method, getter)]
    #[doc = "Getter for the `detail` field of this object."]
    pub fn detail(this: &PlyrStateChangeEvent) -> PlyrStateChangeEventDetail;
}

impl Plyr {
    /// Plyr Constructor with options
    #[cfg(feature = "options")]
    pub fn new_with_options(css_selector: &str, options: &PlyrOptions) -> Plyr {
        let options_js_value =
            serde_wasm_bindgen::to_value(options).expect("PlyrOptions failed serialization");
        Plyr::new_with_options_jsvalue(css_selector, &options_js_value)
    }

    /// Plyr Constructor with HtmlElement and options
    #[cfg(feature = "options")]
    pub fn new_with_html_element_and_options(
        html_element: &HtmlElement,
        options: &PlyrOptions,
    ) -> Plyr {
        let options_js_value =
            serde_wasm_bindgen::to_value(options).expect("PlyrOptions failed serialization");
        Plyr::new_with_html_element_and_options_jsvalue(html_element, &options_js_value)
    }

    /// Plyr.setup with Vec<HtmlElement> and PlyrOptions
    #[cfg(feature = "options")]
    pub fn setup_with_html_elements_and_options(
        html_elements: Vec<HtmlElement>,
        options: &PlyrOptions,
    ) -> Vec<Plyr> {
        let options_js_value =
            serde_wasm_bindgen::to_value(options).expect("PlyrOptions failed serialization");
        Plyr::setup_with_html_elements_and_options_jsvalue(html_elements, &options_js_value)
    }

    /// Plyr.setup with NodeList and options
    #[cfg(feature = "options")]
    pub fn setup_with_node_list_and_options(
        node_list: &NodeList,
        options: &PlyrOptions,
    ) -> Vec<Plyr> {
        let options_js_value =
            serde_wasm_bindgen::to_value(options).expect("PlyrOptions failed serialization");
        Plyr::setup_with_node_list_and_options_jsvalue(node_list, &options_js_value)
    }

    /// Plyr.supported
    pub fn supported_with_info(
        media_type: &MediaType,
        provider: &Provider,
        plays_inline: bool,
    ) -> Support {
        Plyr::supported_with_info_str(&media_type.to_string(), &provider.to_string(), plays_inline)
    }

    /// Getter for the `provider` field of this class.
    pub fn provider(&self) -> Provider {
        self.provider_string()
            .try_into()
            .expect("Provider failed convert from String")
    }

    /// The setPreviewThumbnails` method of this class with PreviewThumbnailsOptions.
    #[cfg(feature = "options")]
    pub fn set_preview_thumbnails(&self, options: &PreviewThumbnailsOptions) {
        let js_value = serde_wasm_bindgen::to_value(options)
            .expect("PreviewThumbnailsOptions failed serialization");
        self.set_preview_thumbnails_jsvalue(&js_value);
    }

    /// Getter for the `source` field of this class.
    #[cfg(feature = "options")]
    pub fn source(&self) -> SourceInfo {
        serde_wasm_bindgen::from_value(self.source_jsvalue())
            .expect("SourceInfo failed deserialization")
    }

    /// Setter for the `source` field of this class.
    #[cfg(feature = "options")]
    pub fn set_source(&self, source: &SourceInfo) {
        let js_value =
            serde_wasm_bindgen::to_value(source).expect("SourceInfo failed serialization");
        self.set_source_jsvalue(&js_value);
    }
}

impl Buttons {
    /// Buttons constructor. Internally js empty object created.
    pub fn new() -> Buttons {
        let object_default = Object::default();
        object_default.unchecked_into()
    }
}

impl Default for Buttons {
    fn default() -> Self {
        Buttons::new()
    }
}

impl Elements {
    /// Elements constructor. Internally js empty object created.
    pub fn new() -> Elements {
        let object_default = Object::default();
        object_default.unchecked_into()
    }
}

impl Default for Elements {
    fn default() -> Self {
        Elements::new()
    }
}

pub enum YoutubeState {
    Unstarted,
    Ended,
    Playing,
    Paused,
    Buffering,
    Cued,
}

impl From<i8> for YoutubeState {
    fn from(value: i8) -> Self {
        match value {
            -1 => Self::Unstarted,
            0 => Self::Ended,
            1 => Self::Playing,
            2 => Self::Paused,
            3 => Self::Buffering,
            5 => Self::Cued,
            _ => panic!("Undefined Youtube State"),
        }
    }
}

impl PlyrStateChangeEventDetail {
    /// Getter for the code field of this object.
    pub fn code(&self) -> YoutubeState {
        self.code_int().into()
    }
}