aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-22 09:16:05 +0200
committerChocobozzz <me@florianbigard.com>2018-05-22 09:17:21 +0200
commite7eb5b399725afe7bae2dac27235a6e9478a2f12 (patch)
treec8e3dbbc50bfb1d6033b995b14977c934d625588 /client/src/assets
parent0b33c5206023de0946b247e767087a518e0dec9a (diff)
downloadPeerTube-e7eb5b399725afe7bae2dac27235a6e9478a2f12.tar.gz
PeerTube-e7eb5b399725afe7bae2dac27235a6e9478a2f12.tar.zst
PeerTube-e7eb5b399725afe7bae2dac27235a6e9478a2f12.zip
Fix play on iOS (grumph)
Diffstat (limited to 'client/src/assets')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index ac04421a7..5789641fe 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -63,7 +63,8 @@ class PeerTubePlugin extends Plugin {
63 constructor (player: videojs.Player, options: PeertubePluginOptions) { 63 constructor (player: videojs.Player, options: PeertubePluginOptions) {
64 super(player, options) 64 super(player, options)
65 65
66 this.autoplay = options.autoplay 66 // Disable auto play on iOS
67 this.autoplay = options.autoplay && this.isIOS() === false
67 68
68 this.startTime = options.startTime 69 this.startTime = options.startTime
69 this.videoFiles = options.videoFiles 70 this.videoFiles = options.videoFiles
@@ -180,6 +181,7 @@ class PeerTubePlugin extends Plugin {
180 oldTorrent.removePeer(oldTorrent['ws']) 181 oldTorrent.removePeer(oldTorrent['ws'])
181 } 182 }
182 183
184 // Render the video in a few seconds? (on resolution change for example, we wait some seconds of the new video resolution)
183 this.addTorrentDelay = setTimeout(() => { 185 this.addTorrentDelay = setTimeout(() => {
184 this.flushVideoFile(previousVideoFile) 186 this.flushVideoFile(previousVideoFile)
185 187
@@ -337,6 +339,12 @@ class PeerTubePlugin extends Plugin {
337 this.tryToPlay() 339 this.tryToPlay()
338 }) 340 })
339 } else { 341 } else {
342 // Don't try on iOS that does not support MediaSource
343 if (this.isIOS()) {
344 this.currentVideoFile = this.videoFiles[0]
345 return this.fallbackToHttp(undefined, false)
346 }
347
340 // Proxy first play 348 // Proxy first play
341 const oldPlay = this.player.play.bind(this.player) 349 const oldPlay = this.player.play.bind(this.player)
342 this.player.play = () => { 350 this.player.play = () => {
@@ -439,7 +447,7 @@ class PeerTubePlugin extends Plugin {
439 return fetch(this.videoViewUrl, { method: 'POST' }) 447 return fetch(this.videoViewUrl, { method: 'POST' })
440 } 448 }
441 449
442 private fallbackToHttp (done: Function) { 450 private fallbackToHttp (done?: Function, play = true) {
443 this.flushVideoFile(this.currentVideoFile, true) 451 this.flushVideoFile(this.currentVideoFile, true)
444 this.torrent = null 452 this.torrent = null
445 453
@@ -449,9 +457,9 @@ class PeerTubePlugin extends Plugin {
449 const httpUrl = this.currentVideoFile.fileUrl 457 const httpUrl = this.currentVideoFile.fileUrl
450 this.player.src = this.savePlayerSrcFunction 458 this.player.src = this.savePlayerSrcFunction
451 this.player.src(httpUrl) 459 this.player.src(httpUrl)
452 this.player.play() 460 if (play) this.tryToPlay()
453 461
454 return done() 462 if (done) return done()
455 } 463 }
456 464
457 private handleError (err: Error | string) { 465 private handleError (err: Error | string) {
@@ -466,6 +474,10 @@ class PeerTubePlugin extends Plugin {
466 this.player.removeClass('vjs-error-display-enabled') 474 this.player.removeClass('vjs-error-display-enabled')
467 } 475 }
468 476
477 private isIOS () {
478 return !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)
479 }
480
469 private alterInactivity () { 481 private alterInactivity () {
470 let saveInactivityTimeout: number 482 let saveInactivityTimeout: number
471 483