): videojs.PlayerOptions {
const commonOptions = options.common
- let autoplay = commonOptions.autoplay
+ let autoplay = this.getAutoPlayValue(commonOptions.autoplay)
let html5 = {}
const plugins: VideoJSPluginOptions = {
? commonOptions.muted
: undefined, // Undefined so the player knows it has to check the local storage
- autoplay: autoplay === true
- ? this.getAutoPlayValue()
- : autoplay,
+ autoplay: this.getAutoPlayValue(autoplay),
poster: commonOptions.poster,
inactivityTimeout: commonOptions.inactivityTimeout,
})
}
- private static getAutoPlayValue () {
+ private static getAutoPlayValue (autoplay: any) {
+ if (autoplay !== true) return autoplay
+
+ const isIOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
+ // Giving up with iOS
+ if (isIOS) return false
+
// We have issues with autoplay and Safari.
// any that tries to play using auto mute seems to work
if (isSafari) return 'any'
this.savedInactivityTimeout = player.options_.inactivityTimeout
- if (options.autoplay === true) this.player.addClass('vjs-has-autoplay')
+ if (options.autoplay) this.player.addClass('vjs-has-autoplay')
this.player.on('autoplay-failure', () => {
this.player.removeClass('vjs-has-autoplay')
private initializePlayer () {
this.buildQualities()
- if (this.autoplay === true) {
+ if (this.autoplay) {
this.player.posterImage.hide()
return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime })