aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmediaelement.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-12-03 12:13:06 -0500
committerGitHub <noreply@github.com>2019-12-03 12:13:06 -0500
commitf31a88d85de2a7bdee65216b3b66b697b459a31d (patch)
tree05d957e792a1e3651c2b775a76327e1898544596 /components/script/dom/htmlmediaelement.rs
parent54d88fd042d3d1d382b36bf5d53308dabc35991d (diff)
parent41ff93eca2bf3e8a15d99fedbf7da3a7f9af638a (diff)
downloadservo-f31a88d85de2a7bdee65216b3b66b697b459a31d.tar.gz
servo-f31a88d85de2a7bdee65216b3b66b697b459a31d.zip
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. -->
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r--components/script/dom/htmlmediaelement.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 651084cfb84..91acd4b97e7 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -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]