From 1536283f5ae0a254f76f0621bcb25284706775dc Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Mon, 26 Jul 2010 10:45:41 +1200 Subject: [PATCH] Bug 534571 - Fire video timeupdate event when starting a new load. r=roc,dolske a=blocking2.0 --- content/html/content/src/nsHTMLMediaElement.cpp | 10 +++++++++- toolkit/content/widgets/videocontrols.xml | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 0a8be4df591..a11427e164a 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -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")); } diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index 950275f3ef2..928f1eb573d 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -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