Skip to content
Snippets Groups Projects
Unverified Commit 0dcf9a14 authored by Chocobozzz's avatar Chocobozzz
Browse files

Fix player error when the media is not supported

parent 27d56b54
No related branches found
No related tags found
No related merge requests found
...@@ -270,7 +270,7 @@ class PeerTubePlugin extends Plugin { ...@@ -270,7 +270,7 @@ class PeerTubePlugin extends Plugin {
this.playerElement = options.playerElement this.playerElement = options.playerElement
this.player.ready(() => { this.player.ready(() => {
this.initializePlayer(options) this.initializePlayer()
this.runTorrentInfoScheduler() this.runTorrentInfoScheduler()
this.runViewAdd() this.runViewAdd()
}) })
...@@ -331,9 +331,10 @@ class PeerTubePlugin extends Plugin { ...@@ -331,9 +331,10 @@ class PeerTubePlugin extends Plugin {
const options = { autoplay: true, controls: true } const options = { autoplay: true, controls: true }
renderVideo(torrent.files[0], this.playerElement, options,(err, renderer) => { renderVideo(torrent.files[0], this.playerElement, options,(err, renderer) => {
this.renderer = renderer
if (err) return this.fallbackToHttp() if (err) return this.fallbackToHttp()
this.renderer = renderer
if (!this.player.paused()) { if (!this.player.paused()) {
const playPromise = this.player.play() const playPromise = this.player.play()
if (playPromise !== undefined) return playPromise.then(done) if (playPromise !== undefined) return playPromise.then(done)
...@@ -406,7 +407,7 @@ class PeerTubePlugin extends Plugin { ...@@ -406,7 +407,7 @@ class PeerTubePlugin extends Plugin {
this.updateVideoFile(undefined, () => this.player.play()) this.updateVideoFile(undefined, () => this.player.play())
} }
private initializePlayer (options: PeertubePluginOptions) { private initializePlayer () {
if (this.autoplay === true) { if (this.autoplay === true) {
this.updateVideoFile(undefined, () => this.player.play()) this.updateVideoFile(undefined, () => this.player.play())
} else { } else {
......
...@@ -58,13 +58,11 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca ...@@ -58,13 +58,11 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
const codecs = getCodec(file.name, useVP9) const codecs = getCodec(file.name, useVP9)
prepareElem() prepareElem()
preparedElem.addEventListener('error', function onError(err) { preparedElem.addEventListener('error', function onError (err) {
// Try with vp9 before returning an error preparedElem.removeEventListener('error', onError)
if (codecs.indexOf('vp8') !== -1) {
preparedElem.removeEventListener('error', onError)
return fallbackToMediaSource(true) // Try with vp9 before returning an error
} if (codecs.indexOf('vp8') !== -1) return fallbackToMediaSource(true)
return callback(err) return callback(err)
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment