Bug 1420488 - part1 : bless media if media has started playing before. r=jwwang

If the media has started playing before, bless it and it would always be allowed
to autoplay.

MozReview-Commit-ID: 4GqMARLXULU
This commit is contained in:
Alastor Wu
2017-11-29 18:59:56 +08:00
parent 2202588cf9
commit f1a57c71e0
3 changed files with 15 additions and 16 deletions

View File

@@ -1979,12 +1979,12 @@ void HTMLMediaElement::DoLoad()
return;
}
// Detect if user has interacted with element so that play will not be
// blocked when initiated by a script. This enables sites to capture user
// intent to play by calling load() in the click handler of a "catalog
// view" of a gallery of videos.
if (EventStateManager::IsHandlingUserInput()) {
mHasUserInteractedLoadOrSeek = true;
// Detect if user has interacted with element so that play will not be
// blocked when initiated by a script. This enables sites to capture user
// intent to play by calling load() in the click handler of a "catalog
// view" of a gallery of videos.
mIsBlessed = true;
// Mark the channel as urgent-start when autopaly so that it will play the
// media from src after loading enough resource.
if (HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) {
@@ -2757,7 +2757,7 @@ HTMLMediaElement::Seek(double aTime,
// Detect if user has interacted with element by seeking so that
// play will not be blocked when initiated by a script.
if (EventStateManager::IsHandlingUserInput()) {
mHasUserInteractedLoadOrSeek = true;
mIsBlessed = true;
}
StopSuspendingAfterFirstFrame();
@@ -4043,7 +4043,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mIsEncrypted(false),
mWaitingForKey(NOT_WAITING_FOR_KEY),
mDisableVideo(false),
mHasUserInteractedLoadOrSeek(false),
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0),
mHasSuspendTaint(false),
@@ -4286,6 +4285,9 @@ HTMLMediaElement::PlayInternal(ErrorResult& aRv)
UpdatePreloadAction();
UpdateSrcMediaStreamPlaying();
// once media start playing, we would always allow it to autoplay
mIsBlessed = true;
// TODO: If the playback has ended, then the user agent must set
// seek to the effective start.