diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2018-12-13 16:35:26 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-01-09 09:28:42 +0100 |
commit | 6c2c3f75b90f075d4f7d23b800706e745cb10f8c (patch) | |
tree | 4a4b7955eada2013d82fc30e8d3e489fa480d6d8 /components/script/dom/htmlmediaelement.rs | |
parent | 9223d6248d4831a86f8172efdb9b6057f329a713 (diff) | |
download | servo-6c2c3f75b90f075d4f7d23b800706e745cb10f8c.tar.gz servo-6c2c3f75b90f075d4f7d23b800706e745cb10f8c.zip |
Implement step 6 of media element 'time marches on' algoritm
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r-- | components/script/dom/htmlmediaelement.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 880ba8ea49c..ecbd5687bf9 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -204,6 +204,9 @@ pub struct HTMLMediaElement { text_tracks_list: MutNullableDom<TextTrackList>, /// Expected content length of the media asset being fetched or played. content_length: Cell<Option<u64>>, + /// Time of last timeupdate notification. + #[ignore_malloc_size_of = "Defined in time"] + next_timeupdate_event: Cell<Timespec>, } /// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate> @@ -261,6 +264,7 @@ impl HTMLMediaElement { played: Rc::new(DomRefCell::new(TimeRangesContainer::new())), text_tracks_list: Default::default(), content_length: Cell::new(None), + next_timeupdate_event: Cell::new(time::get_time() + Duration::milliseconds(250)), } } @@ -303,7 +307,15 @@ impl HTMLMediaElement { /// https://html.spec.whatwg.org/multipage/#time-marches-on fn time_marches_on(&self) { - // TODO: implement this. + // Step 6. + if time::get_time() > self.next_timeupdate_event.get() { + let window = window_from_node(self); + window + .task_manager() + .media_element_task_source() + .queue_simple_event(self.upcast(), atom!("timeupdate"), &window); + self.next_timeupdate_event.set(time::get_time() + Duration::milliseconds(350)); + } } /// <https://html.spec.whatwg.org/multipage/#internal-pause-steps> @@ -1173,6 +1185,7 @@ impl HTMLMediaElement { .borrow_mut() .add(self.playback_position.get(), position); self.playback_position.set(position); + self.time_marches_on(); }, PlayerEvent::StateChanged(ref state) => match *state { PlaybackState::Paused => { |