mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Auto merge of #24885 - shnmorimoto:implement_mediasession_set_positon_state, r=ferjm
Implement mediasession set positon state <!-- Please describe your changes on the following line: --> fix #24808 > Bonus points if you want to tweak the existing UI by adding a progress bar, and the info about the current position and total duration. I haven't implemented this yet. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #24808 (GitHub issue number if applicable) <!-- Either: --> - [x] There are tests for these changes OR <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
f31a88d85d
13 changed files with 183 additions and 34 deletions
|
@ -67,7 +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::{MediaSessionEvent, MediaSessionPlaybackState};
|
||||
use embedder_traits::{MediaPositionState, MediaSessionEvent, MediaSessionPlaybackState};
|
||||
use euclid::default::Size2D;
|
||||
use headers::{ContentLength, ContentRange, HeaderMapExt};
|
||||
use html5ever::{LocalName, Prefix};
|
||||
|
@ -1780,6 +1780,15 @@ impl HTMLMediaElement {
|
|||
.add(self.playback_position.get(), position);
|
||||
self.playback_position.set(position);
|
||||
self.time_marches_on();
|
||||
let media_position_state =
|
||||
MediaPositionState::new(self.duration.get(), self.playbackRate.get(), position);
|
||||
debug!(
|
||||
"Sending media session event set position state {:?}",
|
||||
media_position_state
|
||||
);
|
||||
self.send_media_session_event(MediaSessionEvent::SetPositionState(
|
||||
media_position_state,
|
||||
));
|
||||
},
|
||||
PlayerEvent::SeekData(p, ref seek_lock) => {
|
||||
self.fetch_request(Some(p), Some(seek_lock.clone()));
|
||||
|
@ -1925,6 +1934,18 @@ impl HTMLMediaElement {
|
|||
|
||||
media_session.send_event(event);
|
||||
}
|
||||
|
||||
pub fn set_duration(&self, duration: f64) {
|
||||
self.duration.set(duration);
|
||||
}
|
||||
|
||||
pub fn reset(&self) {
|
||||
if let Some(ref player) = *self.player.borrow() {
|
||||
if let Err(e) = player.lock().unwrap().stop() {
|
||||
eprintln!("Could not stop player {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Placeholder for [https://github.com/servo/servo/issues/22293]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue