-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix safari play() after source change #4639
Fix safari play() after source change #4639
Conversation
I have a similar problem that's happening with Safari 11 for video.js In Safari 11 > Preferences > Websites, I have the website set to When I try to play any content, the videojs pauses the content. I can check this by seeing that videojs triggers Do you think this is the same issue? Or should I file another issue.? |
@serv that's another unrelated issue that's already been addressed as much as we can in video.js. See #4562 and #4582. Also, https://www.brightcove.com/en/blog/2017/09/autoplay is a good overview, I think of the issues. |
Sorry to resurface this issue one more time. After reading, https://webkit.org/blog/6784/new-video-policies-for-ios/, I think the problem I am having is coming from this.
Wouldn't clicking a button, that triggers I think there's definitely something funky happening with video.js still because jumping to a middle of the track using I am currently using
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were talking about this issue this morning and @gkatsev's concerns about unintended consequences. We wonder if we ought to make the if
condition more specific - to target only those Safari versions that are known to have this issue and only when preload
is actually none
?
@misteroneill Yup, minimizing the scope makes sense. I'll make the changes. |
4e90bc9
to
42cc43c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a question about DESKTOP_SAFARI_VERSION
@@ -85,6 +85,14 @@ export const IE_VERSION = (function() { | |||
|
|||
export const IS_SAFARI = (/Safari/i).test(USER_AGENT) && !IS_CHROME && !IS_ANDROID && !IS_EDGE; | |||
export const IS_ANY_SAFARI = IS_SAFARI || IS_IOS; | |||
export const DESKTOP_SAFARI_VERSION = (function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should just be SAFARI_VERSION
? on iOS it'll be equivalent to IOS_VERSION
?
I.e., if you return IOS_VERSION
instead of null
from this iife.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I would find it clearer to have IOS_VERSION
solely responsible for mobile and DESKTOP_SAFARI_VERSION
solely responsible for desktop, rather than a multi-purpose SAFARI_VERSION
, but that's just me. Happy to make this change if you want me to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@videojs/core-committers any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a separate Desktop Safari version would be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think having desktop is better as well
Looks like tests are still failing. |
Recent changes to Player#play have apparently addressed the underlying issue here, so this PR is no longer necessary. Closing. |
Description
Programmatically calling
player.play()
immediately following a source change will fail in Safari (desktop and iOS) if the video element'spreload
attribute is set tonone
.Open the following links in Safari, start playback, then press the "Play new source" button. These samples demonstrate the problem using a vanilla
<video>
element.Expected behavior: the source changes and starts to play.
Actual behavior: playback stalls
One observed effect of this problem is with the implementation of playlists. With
preload: "none"
, playlists, whether configured to autoadvance or click-to-play, do not work in Safari because playback stalls when switching sources.Note: This bug has apparently been fixed in Safari 11.
Specific additions
Modify the
player.play()
method so that if it is called while the content source is still changing in Safari,load()
will be called beforeplay()
.