Introduce embedder MediaSessionEvent and move active session to Servo

This commit is contained in:
Fernando Jiménez Moreno 2019-10-09 12:16:35 +02:00
parent 4d147d2c56
commit 89d9e3ad78
9 changed files with 90 additions and 61 deletions

View file

@ -1087,34 +1087,3 @@ pub enum MediaSessionActionType {
/// The action intent is to move the playback time to a specific time.
SeekTo,
}
/// https://w3c.github.io/mediasession/#mediametadata
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct MediaMetadata {
/// Title
pub title: String,
/// Artist
pub artist: Option<String>,
/// Album
pub album: Option<String>,
}
/// https://w3c.github.io/mediasession/#enumdef-mediasessionplaybackstate
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum MediaSessionPlaybackState {
/// The browsing context does not specify whether its playing or paused.
None_,
/// The browsing context has paused media and it can be resumed.
Playing,
/// The browsing context is currently playing media and it can be paused.
Paused,
}
/// Type of events sent from script to the constellation about the media session.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum MediaSessionEvent {
/// Indicates that the media metadata is available.
SetMetadata(MediaMetadata),
/// Indicates that the playback state has changed.
PlaybackStateChange(MediaSessionPlaybackState),
}

View file

@ -255,9 +255,6 @@ pub enum ScriptMsg {
GetScreenSize(IpcSender<DeviceIntSize>),
/// Get the available screen size (pixel)
GetScreenAvailSize(IpcSender<DeviceIntSize>),
/// Notifies the constellation about media session events
/// (i.e. when there is metadata for the active media session, playback state changes...).
MediaSessionEventMsg(TopLevelBrowsingContextId, MediaSessionEvent),
}
impl fmt::Debug for ScriptMsg {
@ -309,7 +306,6 @@ impl fmt::Debug for ScriptMsg {
GetClientWindow(..) => "GetClientWindow",
GetScreenSize(..) => "GetScreenSize",
GetScreenAvailSize(..) => "GetScreenAvailSize",
MediaSessionEventMsg(..) => "MediaSessionEventMsg",
};
write!(formatter, "ScriptMsg::{}", variant)
}