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
use super::*;
/// The MediaSession class.
/// [`MediaSession`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct MediaSession {
inner: Any,
}
impl FromVal for MediaSession {
fn from_val(v: &Any) -> Self {
MediaSession {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for MediaSession {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for MediaSession {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for MediaSession {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for MediaSession {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<MediaSession> for Any {
fn from(s: MediaSession) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&MediaSession> for Any {
fn from(s: &MediaSession) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(MediaSession);
impl MediaSession {
/// Getter of the `metadata` attribute.
/// [`MediaSession.metadata`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/metadata)
pub fn metadata(&self) -> MediaMetadata {
self.inner.get("metadata").as_::<MediaMetadata>()
}
/// Setter of the `metadata` attribute.
/// [`MediaSession.metadata`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/metadata)
pub fn set_metadata(&mut self, value: &MediaMetadata) {
self.inner.set("metadata", value);
}
}
impl MediaSession {
/// Getter of the `playbackState` attribute.
/// [`MediaSession.playbackState`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/playbackState)
pub fn playback_state(&self) -> MediaSessionPlaybackState {
self.inner
.get("playbackState")
.as_::<MediaSessionPlaybackState>()
}
/// Setter of the `playbackState` attribute.
/// [`MediaSession.playbackState`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/playbackState)
pub fn set_playback_state(&mut self, value: &MediaSessionPlaybackState) {
self.inner.set("playbackState", value);
}
}
impl MediaSession {
/// The setActionHandler method.
/// [`MediaSession.setActionHandler`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setActionHandler)
pub fn set_action_handler(&self, action: &MediaSessionAction, handler: &Function) -> Undefined {
self.inner
.call("setActionHandler", &[action.into(), handler.into()])
.as_::<Undefined>()
}
}
impl MediaSession {
/// The setPositionState method.
/// [`MediaSession.setPositionState`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setPositionState)
pub fn set_position_state(&self) -> Undefined {
self.inner.call("setPositionState", &[]).as_::<Undefined>()
}
}
impl MediaSession {
/// The setPositionState method.
/// [`MediaSession.setPositionState`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setPositionState)
pub fn set_position_state_with_state(&self, state: &MediaPositionState) -> Undefined {
self.inner
.call("setPositionState", &[state.into()])
.as_::<Undefined>()
}
}
impl MediaSession {
/// The setMicrophoneActive method.
/// [`MediaSession.setMicrophoneActive`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setMicrophoneActive)
pub fn set_microphone_active(&self, active: bool) -> Promise<Undefined> {
self.inner
.call("setMicrophoneActive", &[active.into()])
.as_::<Promise<Undefined>>()
}
}
impl MediaSession {
/// The setCameraActive method.
/// [`MediaSession.setCameraActive`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setCameraActive)
pub fn set_camera_active(&self, active: bool) -> Promise<Undefined> {
self.inner
.call("setCameraActive", &[active.into()])
.as_::<Promise<Undefined>>()
}
}
impl MediaSession {
/// The setScreenshareActive method.
/// [`MediaSession.setScreenshareActive`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSession/setScreenshareActive)
pub fn set_screenshare_active(&self, active: bool) -> Promise<Undefined> {
self.inner
.call("setScreenshareActive", &[active.into()])
.as_::<Promise<Undefined>>()
}
}