Bug 654787 - part9: Fire seeking and seeked events when looping back to the beginning; r?jwwang
MozReview-Commit-ID: BMR8AF4vRCf
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -498,16 +498,20 @@ MediaDecoder::OnPlaybackEvent(MediaEvent
{
switch (aEvent) {
case MediaEventType::PlaybackEnded:
PlaybackEnded();
break;
case MediaEventType::SeekStarted:
SeekingStarted();
break;
+ case MediaEventType::Loop:
+ GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("seeking"));
+ GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("seeked"));
+ break;
case MediaEventType::Invalidate:
Invalidate();
break;
case MediaEventType::EnterVideoSuspend:
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozentervideosuspend"));
break;
case MediaEventType::ExitVideoSuspend:
GetOwner()->DispatchAsyncEvent(NS_LITERAL_STRING("mozexitvideosuspend"));
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3494,16 +3494,18 @@ MediaDecoderStateMachine::UpdatePlayback
// period of the stream. So the time over the end should be corrected.
bool loopback = false;
if (mReader->IsLooped()) {
MOZ_ASSERT(mReader->GetPeriod() > TimeUnit::Zero());
clockTime = clockTime % mReader->GetPeriod().ToMicroseconds();
if (clockTime < GetMediaTime()) {
if (ShouldSeamlesslyLoop()) {
loopback = true;
+ // Fire the `seeking` and `seeked` events to meet the HTML spec.
+ mOnPlaybackEvent.Notify(MediaEventType::Loop);
} else { // Stop playing and decoding when looping is cancelled.
StopPlayback();
mAudioDataRequest.DisconnectIfExists();
AudioQueue().Finish();
mAudioCompleted = true;
}
}
}
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -115,16 +115,17 @@ class TaskQueue;
extern LazyLogModule gMediaDecoderLog;
enum class MediaEventType : int8_t
{
PlaybackStarted,
PlaybackStopped,
PlaybackEnded,
SeekStarted,
+ Loop,
Invalidate,
EnterVideoSuspend,
ExitVideoSuspend,
StartVideoSuspendTimer,
CancelVideoSuspendTimer,
VideoOnlySeekBegin,
VideoOnlySeekCompleted,
};