aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-26 15:29:04 +0200
committerChocobozzz <me@florianbigard.com>2018-03-26 15:29:04 +0200
commit0dcf9a14be3f8668fe5ee65cf0365d457b4d1499 (patch)
treeb6f4fa890acdd7dc169c78290069f968ba9dc7f6 /client
parent27d56b545323fd8e8fab545466bcf3002f9c42f0 (diff)
downloadPeerTube-0dcf9a14be3f8668fe5ee65cf0365d457b4d1499.tar.gz
PeerTube-0dcf9a14be3f8668fe5ee65cf0365d457b4d1499.tar.zst
PeerTube-0dcf9a14be3f8668fe5ee65cf0365d457b4d1499.zip
Fix player error when the media is not supported
Diffstat (limited to 'client')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts7
-rw-r--r--client/src/assets/player/video-renderer.ts10
2 files changed, 8 insertions, 9 deletions
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts
index 277603c9b..52846503d 100644
--- a/client/src/assets/player/peertube-videojs-plugin.ts
+++ b/client/src/assets/player/peertube-videojs-plugin.ts
@@ -270,7 +270,7 @@ class PeerTubePlugin extends Plugin {
270 this.playerElement = options.playerElement 270 this.playerElement = options.playerElement
271 271
272 this.player.ready(() => { 272 this.player.ready(() => {
273 this.initializePlayer(options) 273 this.initializePlayer()
274 this.runTorrentInfoScheduler() 274 this.runTorrentInfoScheduler()
275 this.runViewAdd() 275 this.runViewAdd()
276 }) 276 })
@@ -331,9 +331,10 @@ class PeerTubePlugin extends Plugin {
331 331
332 const options = { autoplay: true, controls: true } 332 const options = { autoplay: true, controls: true }
333 renderVideo(torrent.files[0], this.playerElement, options,(err, renderer) => { 333 renderVideo(torrent.files[0], this.playerElement, options,(err, renderer) => {
334 this.renderer = renderer
335
334 if (err) return this.fallbackToHttp() 336 if (err) return this.fallbackToHttp()
335 337
336 this.renderer = renderer
337 if (!this.player.paused()) { 338 if (!this.player.paused()) {
338 const playPromise = this.player.play() 339 const playPromise = this.player.play()
339 if (playPromise !== undefined) return playPromise.then(done) 340 if (playPromise !== undefined) return playPromise.then(done)
@@ -406,7 +407,7 @@ class PeerTubePlugin extends Plugin {
406 this.updateVideoFile(undefined, () => this.player.play()) 407 this.updateVideoFile(undefined, () => this.player.play())
407 } 408 }
408 409
409 private initializePlayer (options: PeertubePluginOptions) { 410 private initializePlayer () {
410 if (this.autoplay === true) { 411 if (this.autoplay === true) {
411 this.updateVideoFile(undefined, () => this.player.play()) 412 this.updateVideoFile(undefined, () => this.player.play())
412 } else { 413 } else {
diff --git a/client/src/assets/player/video-renderer.ts b/client/src/assets/player/video-renderer.ts
index e3415abd3..4affb43cf 100644
--- a/client/src/assets/player/video-renderer.ts
+++ b/client/src/assets/player/video-renderer.ts
@@ -58,13 +58,11 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
58 const codecs = getCodec(file.name, useVP9) 58 const codecs = getCodec(file.name, useVP9)
59 59
60 prepareElem() 60 prepareElem()
61 preparedElem.addEventListener('error', function onError(err) { 61 preparedElem.addEventListener('error', function onError (err) {
62 // Try with vp9 before returning an error 62 preparedElem.removeEventListener('error', onError)
63 if (codecs.indexOf('vp8') !== -1) {
64 preparedElem.removeEventListener('error', onError)
65 63
66 return fallbackToMediaSource(true) 64 // Try with vp9 before returning an error
67 } 65 if (codecs.indexOf('vp8') !== -1) return fallbackToMediaSource(true)
68 66
69 return callback(err) 67 return callback(err)
70 }) 68 })