aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
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
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')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts14
-rw-r--r--client/src/assets/player/peertube-plugin.ts2
-rw-r--r--client/src/assets/player/webtorrent/webtorrent-plugin.ts2
3 files changed, 11 insertions, 7 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'
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts
index 5085f7f86..a5a706420 100644
--- a/client/src/assets/player/peertube-plugin.ts
+++ b/client/src/assets/player/peertube-plugin.ts
@@ -45,7 +45,7 @@ class PeerTubePlugin extends Plugin {
45 45
46 this.savedInactivityTimeout = player.options_.inactivityTimeout 46 this.savedInactivityTimeout = player.options_.inactivityTimeout
47 47
48 if (options.autoplay === true) this.player.addClass('vjs-has-autoplay') 48 if (options.autoplay) this.player.addClass('vjs-has-autoplay')
49 49
50 this.player.on('autoplay-failure', () => { 50 this.player.on('autoplay-failure', () => {
51 this.player.removeClass('vjs-has-autoplay') 51 this.player.removeClass('vjs-has-autoplay')
diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
index cb3deacc6..a894a90f5 100644
--- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts
+++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
@@ -417,7 +417,7 @@ class WebTorrentPlugin extends Plugin {
417 private initializePlayer () { 417 private initializePlayer () {
418 this.buildQualities() 418 this.buildQualities()
419 419
420 if (this.autoplay === true) { 420 if (this.autoplay) {
421 this.player.posterImage.hide() 421 this.player.posterImage.hide()
422 422
423 return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime }) 423 return this.updateVideoFile(undefined, { forcePlay: true, seek: this.startTime })