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
Родитель f1742e072f
Коммит fb6bbafe09
2 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@ -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()

Просмотреть файл

@ -1516,6 +1516,11 @@ private:
// True if the first frame has been successfully loaded.
bool mFirstFrameLoaded;
// Media elements also have a default playback start position, which must
// initially be set to zero seconds. This time is used to allow the element to
// be seeked even before the media is loaded.
double mDefaultPlaybackStartPosition;
};
} // namespace dom