mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Set MediaMetadata MediaSession owner
This commit is contained in:
parent
4b5b4d19bf
commit
1ab65005ae
2 changed files with 11 additions and 5 deletions
|
@ -27,7 +27,6 @@ impl MediaMetadata {
|
||||||
fn new_inherited(init: &MediaMetadataInit) -> MediaMetadata {
|
fn new_inherited(init: &MediaMetadataInit) -> MediaMetadata {
|
||||||
MediaMetadata {
|
MediaMetadata {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
// TODO(ferjm): Set active media session?
|
|
||||||
session: Default::default(),
|
session: Default::default(),
|
||||||
title: DomRefCell::new(init.title.clone()),
|
title: DomRefCell::new(init.title.clone()),
|
||||||
artist: DomRefCell::new(init.artist.clone()),
|
artist: DomRefCell::new(init.artist.clone()),
|
||||||
|
@ -56,6 +55,10 @@ impl MediaMetadata {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_session(&self, session: &MediaSession) {
|
||||||
|
self.session.set(Some(&session));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MediaMetadataMethods for MediaMetadata {
|
impl MediaMetadataMethods for MediaMetadata {
|
||||||
|
|
|
@ -47,8 +47,11 @@ impl MediaSessionMethods for MediaSession {
|
||||||
self.metadata.get()
|
self.metadata.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetMetadata(&self, value: Option<&MediaMetadata>) {
|
fn SetMetadata(&self, metadata: Option<&MediaMetadata>) {
|
||||||
self.metadata.set(value);
|
if let Some(ref metadata) = metadata {
|
||||||
|
metadata.set_session(self);
|
||||||
|
}
|
||||||
|
self.metadata.set(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/mediasession/#dom-mediasession-playbackstate
|
/// https://w3c.github.io/mediasession/#dom-mediasession-playbackstate
|
||||||
|
@ -57,8 +60,8 @@ impl MediaSessionMethods for MediaSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://w3c.github.io/mediasession/#dom-mediasession-playbackstate
|
/// https://w3c.github.io/mediasession/#dom-mediasession-playbackstate
|
||||||
fn SetPlaybackState(&self, value: MediaSessionPlaybackState) {
|
fn SetPlaybackState(&self, state: MediaSessionPlaybackState) {
|
||||||
*self.playback_state.borrow_mut() = value;
|
*self.playback_state.borrow_mut() = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetActionHandler(
|
fn SetActionHandler(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue