mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce embedder MediaSessionEvent and move active session to Servo
This commit is contained in:
parent
4d147d2c56
commit
89d9e3ad78
9 changed files with 90 additions and 61 deletions
|
@ -67,6 +67,7 @@ use crate::script_thread::ScriptThread;
|
|||
use crate::task_source::TaskSource;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::resources::{self, Resource as EmbedderResource};
|
||||
use embedder_traits::{MediaMetadata, MediaSessionEvent};
|
||||
use euclid::default::Size2D;
|
||||
use headers::{ContentLength, ContentRange, HeaderMapExt};
|
||||
use html5ever::{LocalName, Prefix};
|
||||
|
@ -80,7 +81,6 @@ use net_traits::request::{Destination, Referrer};
|
|||
use net_traits::{CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, Metadata};
|
||||
use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType};
|
||||
use script_layout_interface::HTMLMediaData;
|
||||
use script_traits::MediaSessionEvent;
|
||||
use servo_config::pref;
|
||||
use servo_media::player::audio::AudioRenderer;
|
||||
use servo_media::player::video::{VideoFrame, VideoFrameRenderer};
|
||||
|
@ -1727,6 +1727,14 @@ impl HTMLMediaElement {
|
|||
if self.Controls() {
|
||||
self.render_controls();
|
||||
}
|
||||
|
||||
// Send a media session event with the obtained metadata.
|
||||
self.send_media_session_event(MediaSessionEvent::SetMetadata(MediaMetadata {
|
||||
// TODO(ferjm) set url if no title.
|
||||
title: metadata.title.clone().unwrap_or("".to_string()),
|
||||
artist: None,
|
||||
album: None,
|
||||
}));
|
||||
},
|
||||
PlayerEvent::NeedData => {
|
||||
// The player needs more data.
|
||||
|
|
|
@ -16,8 +16,9 @@ use crate::dom::mediametadata::MediaMetadata;
|
|||
use crate::dom::window::Window;
|
||||
use crate::script_thread::ScriptThread;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::{EmbedderMsg, MediaSessionEvent};
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
use script_traits::{MediaSessionActionType, MediaSessionEvent, ScriptMsg};
|
||||
use script_traits::MediaSessionActionType;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
@ -71,14 +72,8 @@ impl MediaSession {
|
|||
|
||||
pub fn send_event(&self, event: MediaSessionEvent) {
|
||||
let global = self.global();
|
||||
let browser_id = global
|
||||
.as_window()
|
||||
.window_proxy()
|
||||
.top_level_browsing_context_id();
|
||||
let _ = global
|
||||
.script_to_constellation_chan()
|
||||
.send(ScriptMsg::MediaSessionEventMsg(browser_id, event))
|
||||
.unwrap();
|
||||
let window = global.as_window();
|
||||
window.send_to_embedder(EmbedderMsg::MediaSessionEvent(event));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue