Bug 1188887: P1. Allow seeking when readyState is HAVE_NOTHING. r=jwwang

This commit is contained in:
Jean-Yves Avenard
2015-10-26 20:36:16 +11:00
parent 95c2826a30
commit c9c13e4f45
2 changed files with 15 additions and 5 deletions

View File

@@ -1404,11 +1404,11 @@ HTMLMediaElement::CurrentTime() const
return stream->StreamTimeToSeconds(stream->GetCurrentTime());
}
if (mDecoder) {
if (mDefaultPlaybackStartPosition == 0.0 && mDecoder) {
return mDecoder->GetCurrentTime();
}
return 0.0;
return mDefaultPlaybackStartPosition;
}
NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime)
@@ -1515,8 +1515,7 @@ HTMLMediaElement::Seek(double aTime,
}
if (mReadyState == nsIDOMHTMLMediaElement::HAVE_NOTHING) {
LOG(LogLevel::Debug, ("%p SetCurrentTime(%f) failed: no source", this, aTime));
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
mDefaultPlaybackStartPosition = aTime;
return;
}
@@ -2114,7 +2113,8 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mMediaStreamTrackListener(nullptr),
mElementInTreeState(ELEMENT_NOT_INTREE),
mHasUserInteraction(false),
mFirstFrameLoaded(false)
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0)
{
if (!gMediaElementLog) {
gMediaElementLog = PR_NewLogModule("nsMediaElement");
@@ -3440,6 +3440,11 @@ void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
// We are a video element playing video so update the screen wakelock
NotifyOwnerDocumentActivityChangedInternal();
}
if (mDefaultPlaybackStartPosition > 0) {
SetCurrentTime(mDefaultPlaybackStartPosition);
mDefaultPlaybackStartPosition = 0.0;
}
}
void HTMLMediaElement::FirstFrameLoaded()