mirror of
https://github.com/servo/servo.git
synced 2025-07-29 02:00:23 +01:00
Send MediaSessionAction from Android
This commit is contained in:
parent
b494acbf19
commit
08f9f17ed3
10 changed files with 64 additions and 15 deletions
|
@ -1913,12 +1913,6 @@ impl HTMLMediaElement {
|
|||
self.media_element_load_algorithm();
|
||||
}
|
||||
}
|
||||
|
||||
fn send_media_session_event(&self, event: MediaSessionEvent) {
|
||||
let global = self.global();
|
||||
let media_session = global.as_window().Navigator().MediaSession();
|
||||
media_session.send_event(event);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Placeholder for [https://github.com/servo/servo/issues/22293]
|
||||
|
|
|
@ -61,6 +61,7 @@ impl MediaSession {
|
|||
}
|
||||
|
||||
pub fn handle_action(&self, action: MediaSessionActionType) {
|
||||
println!("HANDLE ACTION {:?}", action);
|
||||
if let Some(handler) = self.action_handlers.borrow().get(&action) {
|
||||
if handler.Call__(ExceptionHandling::Report).is_err() {
|
||||
warn!("Error calling MediaSessionActionHandler callback");
|
||||
|
|
|
@ -1087,3 +1087,20 @@ pub enum MediaSessionActionType {
|
|||
/// The action intent is to move the playback time to a specific time.
|
||||
SeekTo,
|
||||
}
|
||||
|
||||
impl From<i32> for MediaSessionActionType {
|
||||
fn from(value: i32) -> MediaSessionActionType {
|
||||
match value {
|
||||
1 => MediaSessionActionType::Play,
|
||||
2 => MediaSessionActionType::Pause,
|
||||
3 => MediaSessionActionType::SeekBackward,
|
||||
4 => MediaSessionActionType::SeekForward,
|
||||
5 => MediaSessionActionType::PreviousTrack,
|
||||
6 => MediaSessionActionType::NextTrack,
|
||||
7 => MediaSessionActionType::SkipAd,
|
||||
8 => MediaSessionActionType::Stop,
|
||||
9 => MediaSessionActionType::SeekTo,
|
||||
_ => panic!("Unknown MediaSessionActionType"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue