Bug 534571 - Fire video timeupdate event when starting a new load. r=roc,dolske a=blocking2.0

This commit is contained in:
Chris Pearce 2010-07-26 10:45:41 +12:00
parent 86e38ce4c9
commit 1536283f5a
2 changed files with 10 additions and 1 deletions

View File

@ -478,7 +478,9 @@ void nsHTMLMediaElement::AbortExistingLoads()
// with a different load ID to silently be cancelled.
mCurrentLoadID++;
PRBool fireTimeUpdate = PR_FALSE;
if (mDecoder) {
fireTimeUpdate = mDecoder->GetCurrentTime() != 0.0;
mDecoder->Shutdown();
mDecoder = nsnull;
}
@ -505,7 +507,13 @@ void nsHTMLMediaElement::AbortExistingLoads()
ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_NOTHING);
mPaused = PR_TRUE;
// TODO: The current playback position must be set to 0.
if (fireTimeUpdate) {
// Since we destroyed the decoder above, the current playback position
// will now be reported as 0. The playback position was non-zero when
// we destroyed the decoder, so fire a timeupdate event so that the
// change will be reflected in the controls.
DispatchAsyncSimpleEvent(NS_LITERAL_STRING("timeupdate"));
}
DispatchSimpleEvent(NS_LITERAL_STRING("emptied"));
}

View File

@ -448,6 +448,7 @@
this.maxCurrentTimeSeen = 0;
this.statusIcon.setAttribute("type", "throbber");
this.isAudioOnly = (this.video instanceof HTMLAudioElement);
this.setPlayButtonState(true);
break;
case "durationchange":
var duration = Math.round(this.video.duration * 1000); // in ms