From b7b4ef3fd4300fbcc0606c3bebdaa5f13ec010e8 Mon Sep 17 00:00:00 2001 From: Michael Rosenberg Date: Mon, 6 Jun 2022 14:06:48 -0400 Subject: [PATCH] Add mediasession api (#2926) * Added MediaSession API to web-sys * Added WebIDL inclusion instructions to web-sys README --- crates/web-sys/Cargo.toml | 8 ++ crates/web-sys/README.md | 18 +++ crates/web-sys/src/features/gen_MediaImage.rs | 82 +++++++++++ .../web-sys/src/features/gen_MediaMetadata.rs | 129 ++++++++++++++++++ .../src/features/gen_MediaMetadataInit.rs | 109 +++++++++++++++ .../src/features/gen_MediaPositionState.rs | 99 ++++++++++++++ .../web-sys/src/features/gen_MediaSession.rs | 127 +++++++++++++++++ .../src/features/gen_MediaSessionAction.rs | 25 ++++ .../features/gen_MediaSessionActionDetails.rs | 114 ++++++++++++++++ .../features/gen_MediaSessionPlaybackState.rs | 16 +++ crates/web-sys/src/features/gen_Navigator.rs | 12 ++ crates/web-sys/src/features/mod.rs | 48 +++++++ .../webidls/unstable/MediaSession.webidl | 77 +++++++++++ 13 files changed, 864 insertions(+) create mode 100644 crates/web-sys/src/features/gen_MediaImage.rs create mode 100644 crates/web-sys/src/features/gen_MediaMetadata.rs create mode 100644 crates/web-sys/src/features/gen_MediaMetadataInit.rs create mode 100644 crates/web-sys/src/features/gen_MediaPositionState.rs create mode 100644 crates/web-sys/src/features/gen_MediaSession.rs create mode 100644 crates/web-sys/src/features/gen_MediaSessionAction.rs create mode 100644 crates/web-sys/src/features/gen_MediaSessionActionDetails.rs create mode 100644 crates/web-sys/src/features/gen_MediaSessionPlaybackState.rs create mode 100644 crates/web-sys/webidls/unstable/MediaSession.webidl diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 42ccfc8012d..1911a0fa7ee 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -740,6 +740,7 @@ MediaEncodingConfiguration = [] MediaEncodingType = [] MediaEncryptedEvent = ["Event"] MediaError = [] +MediaImage = [] MediaKeyError = ["Event"] MediaKeyMessageEvent = ["Event"] MediaKeyMessageEventInit = [] @@ -757,6 +758,9 @@ MediaKeys = [] MediaKeysPolicy = [] MediaKeysRequirement = [] MediaList = [] +MediaMetadata = [] +MediaMetadataInit = [] +MediaPositionState = [] MediaQueryList = ["EventTarget"] MediaQueryListEvent = ["Event"] MediaQueryListEventInit = [] @@ -764,6 +768,10 @@ MediaRecorder = ["EventTarget"] MediaRecorderErrorEvent = ["Event"] MediaRecorderErrorEventInit = [] MediaRecorderOptions = [] +MediaSession = [] +MediaSessionAction = [] +MediaSessionActionDetails = [] +MediaSessionPlaybackState = [] MediaSource = ["EventTarget"] MediaSourceEndOfStreamError = [] MediaSourceEnum = [] diff --git a/crates/web-sys/README.md b/crates/web-sys/README.md index ed6892e6604..cfbb3517f43 100644 --- a/crates/web-sys/README.md +++ b/crates/web-sys/README.md @@ -14,3 +14,21 @@ found in `crates/web-sys/Cargo.toml`, but the rule of thumb for `web-sys` is that each type has its own cargo feature (named after the type). Using an API requires enabling the features for all types used in the API, and APIs should mention in the documentation what features they require. + +## How to add an interface + +If you don't see a particular web API in `web-sys`, here is how to add it. + +1. Copy the WebIDL specification of the API and place it in a new file in the + `webidls/unstable` folder. You can often find the IDL by going to the MDN + docs page for the API, scrolling to the bottom, clicking the + "Specifications" link, and scrolling to the bottom of the specification + page. For example, the bottom of the [MDN + docs](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession) on the + MediaSession API takes you to the + [spec](https://w3c.github.io/mediasession/#the-mediasession-interface). The + [very bottom](https://w3c.github.io/mediasession/#idl-index) of _that_ page + is the IDL. +2. Run `cargo run --release --package wasm-bindgen-webidl -- webidls src/features` +3. Copy the contents of `features` into the `[features]` section of `Cargo.toml` +4. Run `git add .` to add all the generated files into git. diff --git a/crates/web-sys/src/features/gen_MediaImage.rs b/crates/web-sys/src/features/gen_MediaImage.rs new file mode 100644 index 00000000000..5a58a88bc4a --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaImage.rs @@ -0,0 +1,82 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaImage)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `MediaImage` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type MediaImage; +} +#[cfg(web_sys_unstable_apis)] +impl MediaImage { + #[doc = "Construct a new `MediaImage`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(src: &str) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.src(src); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `sizes` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn sizes(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("sizes"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `src` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn src(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("src"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `type` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaImage`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn type_(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("type"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_MediaMetadata.rs b/crates/web-sys/src/features/gen_MediaMetadata.rs new file mode 100644 index 00000000000..6911f663ceb --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaMetadata.rs @@ -0,0 +1,129 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaMetadata , typescript_type = "MediaMetadata")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `MediaMetadata` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type MediaMetadata; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "MediaMetadata" , js_name = title)] + #[doc = "Getter for the `title` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/title)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn title(this: &MediaMetadata) -> String; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , setter , js_class = "MediaMetadata" , js_name = title)] + #[doc = "Setter for the `title` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/title)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_title(this: &MediaMetadata, value: &str); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "MediaMetadata" , js_name = artist)] + #[doc = "Getter for the `artist` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/artist)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn artist(this: &MediaMetadata) -> String; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , setter , js_class = "MediaMetadata" , js_name = artist)] + #[doc = "Setter for the `artist` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/artist)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_artist(this: &MediaMetadata, value: &str); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "MediaMetadata" , js_name = album)] + #[doc = "Getter for the `album` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/album)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn album(this: &MediaMetadata) -> String; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , setter , js_class = "MediaMetadata" , js_name = album)] + #[doc = "Setter for the `album` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/album)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_album(this: &MediaMetadata, value: &str); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "MediaMetadata" , js_name = artwork)] + #[doc = "Getter for the `artwork` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/artwork)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn artwork(this: &MediaMetadata) -> ::js_sys::Array; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , setter , js_class = "MediaMetadata" , js_name = artwork)] + #[doc = "Setter for the `artwork` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/artwork)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_artwork(this: &MediaMetadata, value: &::wasm_bindgen::JsValue); + #[cfg(web_sys_unstable_apis)] + #[wasm_bindgen(catch, constructor, js_class = "MediaMetadata")] + #[doc = "The `new MediaMetadata(..)` constructor, creating a new instance of `MediaMetadata`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/MediaMetadata)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaMetadataInit")] + #[wasm_bindgen(catch, constructor, js_class = "MediaMetadata")] + #[doc = "The `new MediaMetadata(..)` constructor, creating a new instance of `MediaMetadata`."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaMetadata/MediaMetadata)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`, `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new_with_init(init: &MediaMetadataInit) -> Result; +} diff --git a/crates/web-sys/src/features/gen_MediaMetadataInit.rs b/crates/web-sys/src/features/gen_MediaMetadataInit.rs new file mode 100644 index 00000000000..4551618b585 --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaMetadataInit.rs @@ -0,0 +1,109 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaMetadataInit)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `MediaMetadataInit` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type MediaMetadataInit; +} +#[cfg(web_sys_unstable_apis)] +impl MediaMetadataInit { + #[doc = "Construct a new `MediaMetadataInit`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `album` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn album(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("album"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `artist` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn artist(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("artist"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `artwork` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn artwork(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("artwork"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `title` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadataInit`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn title(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("title"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for MediaMetadataInit { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_MediaPositionState.rs b/crates/web-sys/src/features/gen_MediaPositionState.rs new file mode 100644 index 00000000000..452f445cede --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaPositionState.rs @@ -0,0 +1,99 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaPositionState)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `MediaPositionState` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaPositionState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type MediaPositionState; +} +#[cfg(web_sys_unstable_apis)] +impl MediaPositionState { + #[doc = "Construct a new `MediaPositionState`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaPositionState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new() -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `duration` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaPositionState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn duration(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("duration"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `playbackRate` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaPositionState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn playback_rate(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("playbackRate"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `position` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaPositionState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn position(&mut self, val: f64) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("position"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for MediaPositionState { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_MediaSession.rs b/crates/web-sys/src/features/gen_MediaSession.rs new file mode 100644 index 00000000000..5f50eec8c4d --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaSession.rs @@ -0,0 +1,127 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaSession , typescript_type = "MediaSession")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `MediaSession` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type MediaSession; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaMetadata")] + # [wasm_bindgen (structural , method , getter , js_class = "MediaSession" , js_name = metadata)] + #[doc = "Getter for the `metadata` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/metadata)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`, `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn metadata(this: &MediaSession) -> Option; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaMetadata")] + # [wasm_bindgen (structural , method , setter , js_class = "MediaSession" , js_name = metadata)] + #[doc = "Setter for the `metadata` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/metadata)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaMetadata`, `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_metadata(this: &MediaSession, value: Option<&MediaMetadata>); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaSessionPlaybackState")] + # [wasm_bindgen (structural , method , getter , js_class = "MediaSession" , js_name = playbackState)] + #[doc = "Getter for the `playbackState` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/playbackState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`, `MediaSessionPlaybackState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn playback_state(this: &MediaSession) -> MediaSessionPlaybackState; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaSessionPlaybackState")] + # [wasm_bindgen (structural , method , setter , js_class = "MediaSession" , js_name = playbackState)] + #[doc = "Setter for the `playbackState` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/playbackState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`, `MediaSessionPlaybackState`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_playback_state(this: &MediaSession, value: MediaSessionPlaybackState); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaSessionAction")] + # [wasm_bindgen (method , structural , js_class = "MediaSession" , js_name = setActionHandler)] + #[doc = "The `setActionHandler()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setActionHandler)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`, `MediaSessionAction`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_action_handler( + this: &MediaSession, + action: MediaSessionAction, + handler: Option<&::js_sys::Function>, + ); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (method , structural , js_class = "MediaSession" , js_name = setCameraActive)] + #[doc = "The `setCameraActive()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setCameraActive)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_camera_active(this: &MediaSession, active: bool); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (method , structural , js_class = "MediaSession" , js_name = setMicrophoneActive)] + #[doc = "The `setMicrophoneActive()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setMicrophoneActive)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_microphone_active(this: &MediaSession, active: bool); + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (method , structural , js_class = "MediaSession" , js_name = setPositionState)] + #[doc = "The `setPositionState()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setPositionState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_position_state(this: &MediaSession); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaPositionState")] + # [wasm_bindgen (method , structural , js_class = "MediaSession" , js_name = setPositionState)] + #[doc = "The `setPositionState()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setPositionState)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaPositionState`, `MediaSession`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn set_position_state_with_state(this: &MediaSession, state: &MediaPositionState); +} diff --git a/crates/web-sys/src/features/gen_MediaSessionAction.rs b/crates/web-sys/src/features/gen_MediaSessionAction.rs new file mode 100644 index 00000000000..b25bf3065e2 --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaSessionAction.rs @@ -0,0 +1,25 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `MediaSessionAction` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `MediaSessionAction`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MediaSessionAction { + Play = "play", + Pause = "pause", + Seekbackward = "seekbackward", + Seekforward = "seekforward", + Previoustrack = "previoustrack", + Nexttrack = "nexttrack", + Skipad = "skipad", + Stop = "stop", + Seekto = "seekto", + Togglemicrophone = "togglemicrophone", + Togglecamera = "togglecamera", + Hangup = "hangup", +} diff --git a/crates/web-sys/src/features/gen_MediaSessionActionDetails.rs b/crates/web-sys/src/features/gen_MediaSessionActionDetails.rs new file mode 100644 index 00000000000..f530e8f985f --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaSessionActionDetails.rs @@ -0,0 +1,114 @@ +#![allow(unused_imports)] +use super::*; +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +extern "C" { + # [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaSessionActionDetails)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `MediaSessionActionDetails` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSessionActionDetails`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub type MediaSessionActionDetails; +} +#[cfg(web_sys_unstable_apis)] +impl MediaSessionActionDetails { + #[cfg(feature = "MediaSessionAction")] + #[doc = "Construct a new `MediaSessionActionDetails`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSessionAction`, `MediaSessionActionDetails`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn new(action: MediaSessionAction) -> Self { + #[allow(unused_mut)] + let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new()); + ret.action(action); + ret + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaSessionAction")] + #[doc = "Change the `action` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSessionAction`, `MediaSessionActionDetails`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn action(&mut self, val: MediaSessionAction) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("action"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `fastSeek` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSessionActionDetails`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn fast_seek(&mut self, val: Option) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("fastSeek"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `seekOffset` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSessionActionDetails`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn seek_offset(&mut self, val: Option) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("seekOffset"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `seekTime` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSessionActionDetails`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn seek_time(&mut self, val: Option) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("seekTime"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} diff --git a/crates/web-sys/src/features/gen_MediaSessionPlaybackState.rs b/crates/web-sys/src/features/gen_MediaSessionPlaybackState.rs new file mode 100644 index 00000000000..77ea9df5904 --- /dev/null +++ b/crates/web-sys/src/features/gen_MediaSessionPlaybackState.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `MediaSessionPlaybackState` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `MediaSessionPlaybackState`*"] +#[doc = ""] +#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] +#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MediaSessionPlaybackState { + None = "none", + Paused = "paused", + Playing = "playing", +} diff --git a/crates/web-sys/src/features/gen_Navigator.rs b/crates/web-sys/src/features/gen_Navigator.rs index 19e76045e3c..902d8816f81 100644 --- a/crates/web-sys/src/features/gen_Navigator.rs +++ b/crates/web-sys/src/features/gen_Navigator.rs @@ -129,6 +129,18 @@ extern "C" { #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] pub fn clipboard(this: &Navigator) -> Option; #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "MediaSession")] + # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = mediaSession)] + #[doc = "Getter for the `mediaSession` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/mediaSession)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `MediaSession`, `Navigator`*"] + #[doc = ""] + #[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"] + #[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"] + pub fn media_session(this: &Navigator) -> MediaSession; + #[cfg(web_sys_unstable_apis)] #[cfg(feature = "WakeLock")] # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = wakeLock)] #[doc = "Getter for the `wakeLock` field of this object."] diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index b3cb8763864..c18588a32e1 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -4258,6 +4258,12 @@ mod gen_MediaError; #[cfg(feature = "MediaError")] pub use gen_MediaError::*; +#[cfg(feature = "MediaImage")] +#[allow(non_snake_case)] +mod gen_MediaImage; +#[cfg(feature = "MediaImage")] +pub use gen_MediaImage::*; + #[cfg(feature = "MediaKeyError")] #[allow(non_snake_case)] mod gen_MediaKeyError; @@ -4360,6 +4366,24 @@ mod gen_MediaList; #[cfg(feature = "MediaList")] pub use gen_MediaList::*; +#[cfg(feature = "MediaMetadata")] +#[allow(non_snake_case)] +mod gen_MediaMetadata; +#[cfg(feature = "MediaMetadata")] +pub use gen_MediaMetadata::*; + +#[cfg(feature = "MediaMetadataInit")] +#[allow(non_snake_case)] +mod gen_MediaMetadataInit; +#[cfg(feature = "MediaMetadataInit")] +pub use gen_MediaMetadataInit::*; + +#[cfg(feature = "MediaPositionState")] +#[allow(non_snake_case)] +mod gen_MediaPositionState; +#[cfg(feature = "MediaPositionState")] +pub use gen_MediaPositionState::*; + #[cfg(feature = "MediaQueryList")] #[allow(non_snake_case)] mod gen_MediaQueryList; @@ -4402,6 +4426,30 @@ mod gen_MediaRecorderOptions; #[cfg(feature = "MediaRecorderOptions")] pub use gen_MediaRecorderOptions::*; +#[cfg(feature = "MediaSession")] +#[allow(non_snake_case)] +mod gen_MediaSession; +#[cfg(feature = "MediaSession")] +pub use gen_MediaSession::*; + +#[cfg(feature = "MediaSessionAction")] +#[allow(non_snake_case)] +mod gen_MediaSessionAction; +#[cfg(feature = "MediaSessionAction")] +pub use gen_MediaSessionAction::*; + +#[cfg(feature = "MediaSessionActionDetails")] +#[allow(non_snake_case)] +mod gen_MediaSessionActionDetails; +#[cfg(feature = "MediaSessionActionDetails")] +pub use gen_MediaSessionActionDetails::*; + +#[cfg(feature = "MediaSessionPlaybackState")] +#[allow(non_snake_case)] +mod gen_MediaSessionPlaybackState; +#[cfg(feature = "MediaSessionPlaybackState")] +pub use gen_MediaSessionPlaybackState::*; + #[cfg(feature = "MediaSource")] #[allow(non_snake_case)] mod gen_MediaSource; diff --git a/crates/web-sys/webidls/unstable/MediaSession.webidl b/crates/web-sys/webidls/unstable/MediaSession.webidl new file mode 100644 index 00000000000..91133c68215 --- /dev/null +++ b/crates/web-sys/webidls/unstable/MediaSession.webidl @@ -0,0 +1,77 @@ +[Exposed=Window] +partial interface Navigator { + [SameObject] readonly attribute MediaSession mediaSession; +}; + +enum MediaSessionPlaybackState { + "none", + "paused", + "playing" +}; + +enum MediaSessionAction { + "play", + "pause", + "seekbackward", + "seekforward", + "previoustrack", + "nexttrack", + "skipad", + "stop", + "seekto", + "togglemicrophone", + "togglecamera", + "hangup" +}; + +callback MediaSessionActionHandler = undefined(MediaSessionActionDetails details); + +[Exposed=Window] +interface MediaSession { + attribute MediaMetadata? metadata; + + attribute MediaSessionPlaybackState playbackState; + + undefined setActionHandler(MediaSessionAction action, MediaSessionActionHandler? handler); + + undefined setPositionState(optional MediaPositionState state = {}); + + undefined setMicrophoneActive(boolean active); + + undefined setCameraActive(boolean active); +}; + +[Exposed=Window] +interface MediaMetadata { + constructor(optional MediaMetadataInit init = {}); + attribute DOMString title; + attribute DOMString artist; + attribute DOMString album; + attribute FrozenArray artwork; +}; + +dictionary MediaMetadataInit { + DOMString title = ""; + DOMString artist = ""; + DOMString album = ""; + sequence artwork = []; +}; + +dictionary MediaImage { + required USVString src; + DOMString sizes = ""; + DOMString type = ""; +}; + +dictionary MediaPositionState { + double duration; + double playbackRate; + double position; +}; + +dictionary MediaSessionActionDetails { + required MediaSessionAction action; + double? seekOffset; + double? seekTime; + boolean? fastSeek; +};