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
use delegate::delegate; #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum AudioTrackKind { Alternative, Descriptions, Main, MainDescriptions, Translation, Commentary, } pub struct AudioTrack { inner: web_sys::AudioTrack, } impl AudioTrack { delegate! { target self.inner { pub fn id(&self) -> String; pub fn label(&self) -> String; pub fn language(&self) -> String; pub fn enabled(&self) -> bool; pub fn set_enabled(&self, enabled: bool); } } pub fn kind(&self) -> Option<AudioTrackKind> { match &*self.inner.kind() { "alternative" => Some(AudioTrackKind::Alternative), "descriptions" => Some(AudioTrackKind::Descriptions), "main" => Some(AudioTrackKind::Main), "main-desc" => Some(AudioTrackKind::MainDescriptions), "translation" => Some(AudioTrackKind::Translation), "commentary" => Some(AudioTrackKind::Commentary), _ => None, } } } impl From<web_sys::AudioTrack> for AudioTrack { fn from(inner: web_sys::AudioTrack) -> Self { AudioTrack { inner } } } impl AsRef<web_sys::AudioTrack> for AudioTrack { fn as_ref(&self) -> &web_sys::AudioTrack { &self.inner } }