Bug 1420192 - when disable autoplay, allow script calls play() once user triggered load() or seek(). r=jwwang
This patch is mainly reverting the changing of bug1382574 part3, but not all the same. Since youtube would call load() when user clicks to play, and then call play() later. For the old pref (checking user-input-play), we should still allow the following play() even it's not triggered via user input. It's also same for seeking, Youtube would call play() after seeking completed. In this patch, we would allow the script-calling once play() if user has called load() or seek() before that. MozReview-Commit-ID: 1UcxRCVfhnR
This commit is contained in:
@@ -1979,7 +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;
|
||||
// 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)) {
|
||||
@@ -2749,6 +2754,12 @@ HTMLMediaElement::Seek(double aTime,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
StopSuspendingAfterFirstFrame();
|
||||
|
||||
if (mSrcStream) {
|
||||
@@ -4032,6 +4043,7 @@ 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),
|
||||
|
||||
Reference in New Issue
Block a user