aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-11 17:48:25 +0200
committerChocobozzz <me@florianbigard.com>2020-05-11 17:48:56 +0200
commit72efdda586489bf59ac7df12ff9e75a926f1f048 (patch)
treee41d7390f554ef1f2bc341da4b0c0220867b7323 /client/src/assets/player/peertube-player-manager.ts
parent6422847473a7dd1aa6066d2735a66a47a956f5e4 (diff)
downloadPeerTube-72efdda586489bf59ac7df12ff9e75a926f1f048.tar.gz
PeerTube-72efdda586489bf59ac7df12ff9e75a926f1f048.tar.zst
PeerTube-72efdda586489bf59ac7df12ff9e75a926f1f048.zip
Try to fix auto play on apple devices
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 61da6a4cb..5ebc247f2 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -187,7 +187,7 @@ export class PeertubePlayerManager {
187 ): videojs.PlayerOptions { 187 ): videojs.PlayerOptions {
188 const commonOptions = options.common 188 const commonOptions = options.common
189 189
190 let autoplay = commonOptions.autoplay 190 let autoplay = this.getAutoPlayValue(commonOptions.autoplay)
191 let html5 = {} 191 let html5 = {}
192 192
193 const plugins: VideoJSPluginOptions = { 193 const plugins: VideoJSPluginOptions = {
@@ -232,9 +232,7 @@ export class PeertubePlayerManager {
232 ? commonOptions.muted 232 ? commonOptions.muted
233 : undefined, // Undefined so the player knows it has to check the local storage 233 : undefined, // Undefined so the player knows it has to check the local storage
234 234
235 autoplay: autoplay === true 235 autoplay: this.getAutoPlayValue(autoplay),
236 ? this.getAutoPlayValue()
237 : autoplay,
238 236
239 poster: commonOptions.poster, 237 poster: commonOptions.poster,
240 inactivityTimeout: commonOptions.inactivityTimeout, 238 inactivityTimeout: commonOptions.inactivityTimeout,
@@ -510,9 +508,15 @@ export class PeertubePlayerManager {
510 }) 508 })
511 } 509 }
512 510
513 private static getAutoPlayValue () { 511 private static getAutoPlayValue (autoplay: any) {
512 if (autoplay !== true) return autoplay
513
514 const isIOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)
514 const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) 515 const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
515 516
517 // Giving up with iOS
518 if (isIOS) return false
519
516 // We have issues with autoplay and Safari. 520 // We have issues with autoplay and Safari.
517 // any that tries to play using auto mute seems to work 521 // any that tries to play using auto mute seems to work
518 if (isSafari) return 'any' 522 if (isSafari) return 'any'