mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix media session action handling
This commit is contained in:
parent
9da1dd3592
commit
b048d7faf7
9 changed files with 54 additions and 121 deletions
|
@ -21,7 +21,6 @@ use crate::dom::promise::Promise;
|
|||
use crate::dom::serviceworkercontainer::ServiceWorkerContainer;
|
||||
use crate::dom::window::Window;
|
||||
use crate::dom::xr::XR;
|
||||
use crate::script_thread::ScriptThread;
|
||||
use dom_struct::dom_struct;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -194,23 +193,16 @@ impl NavigatorMethods for Navigator {
|
|||
/// https://w3c.github.io/mediasession/#dom-navigator-mediasession
|
||||
fn MediaSession(&self) -> DomRoot<MediaSession> {
|
||||
self.mediasession.or_init(|| {
|
||||
// There is a single MediaSession instance per browsing context
|
||||
// There is a single MediaSession instance per Pipeline
|
||||
// and only one active MediaSession globally.
|
||||
//
|
||||
// MediaSession creation can happen in two cases:
|
||||
//
|
||||
// - If content gets `navigator.mediaSession`
|
||||
// - If a media instance (HTMLMediaElement so far) starts playing media.
|
||||
//
|
||||
// The MediaSession constructor is in charge of registering itself with
|
||||
// the script thread.
|
||||
let global = self.global();
|
||||
let window = global.as_window();
|
||||
let browsing_context_id = window.window_proxy().browsing_context_id();
|
||||
match ScriptThread::get_media_session(browsing_context_id) {
|
||||
Some(session) => session,
|
||||
None => MediaSession::new(window),
|
||||
}
|
||||
MediaSession::new(window)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue