mirror of https://github.com/Chocobozzz/PeerTube
Try to fix auto play on apple devices
parent
6422847473
commit
72efdda586
|
@ -187,7 +187,7 @@ export class PeertubePlayerManager {
|
||||||
): videojs.PlayerOptions {
|
): videojs.PlayerOptions {
|
||||||
const commonOptions = options.common
|
const commonOptions = options.common
|
||||||
|
|
||||||
let autoplay = commonOptions.autoplay
|
let autoplay = this.getAutoPlayValue(commonOptions.autoplay)
|
||||||
let html5 = {}
|
let html5 = {}
|
||||||
|
|
||||||
const plugins: VideoJSPluginOptions = {
|
const plugins: VideoJSPluginOptions = {
|
||||||
|
@ -232,9 +232,7 @@ export class PeertubePlayerManager {
|
||||||
? commonOptions.muted
|
? commonOptions.muted
|
||||||
: undefined, // Undefined so the player knows it has to check the local storage
|
: undefined, // Undefined so the player knows it has to check the local storage
|
||||||
|
|
||||||
autoplay: autoplay === true
|
autoplay: this.getAutoPlayValue(autoplay),
|
||||||
? this.getAutoPlayValue()
|
|
||||||
: autoplay,
|
|
||||||
|
|
||||||
poster: commonOptions.poster,
|
poster: commonOptions.poster,
|
||||||
inactivityTimeout: commonOptions.inactivityTimeout,
|
inactivityTimeout: commonOptions.inactivityTimeout,
|
||||||
|
@ -510,9 +508,15 @@ export class PeertubePlayerManager {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
|
||||||
|
|
||||||
|
// Giving up with iOS
|
||||||
|
if (isIOS) return false
|
||||||
|
|
||||||
// We have issues with autoplay and Safari.
|
// We have issues with autoplay and Safari.
|
||||||
// any that tries to play using auto mute seems to work
|
// any that tries to play using auto mute seems to work
|
||||||
if (isSafari) return 'any'
|
if (isSafari) return 'any'
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PeerTubePlugin extends Plugin {
|
||||||
|
|
||||||
this.savedInactivityTimeout = player.options_.inactivityTimeout
|
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.on('autoplay-failure', () => {
|
||||||
this.player.removeClass('vjs-has-autoplay')
|
this.player.removeClass('vjs-has-autoplay')
|
||||||
|
|
|
@ -417,7 +417,7 @@ class WebTorrentPlugin extends Plugin {
|
||||||
private initializePlayer () {
|
private initializePlayer () {
|
||||||
this.buildQualities()
|
this.buildQualities()
|
||||||
|
|
||||||
if (this.autoplay === true) {
|
if (this.autoplay) {
|
||||||
this.player.posterImage.hide()
|
this.player.posterImage.hide()
|
||||||
|
|
||||||
return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime })
|
return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime })
|
||||||
|
|
Loading…
Reference in New Issue