X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fassets%2Fplayer%2Fpeertube-videojs-plugin.ts;h=125ef64a4663d8db8f620dc1c031c2490a13c9d2;hb=481d35966fe49e9a5d3442b658e35403e9464322;hp=5ccfdce36b8ad127dac80119206a6bff6bcee690;hpb=0bc22f8d7ef0ddb4becae2e9453378d3a0f88218;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 5ccfdce36..125ef64a4 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts @@ -217,10 +217,15 @@ class PeerTubePlugin extends Plugin { private playerElement: HTMLVideoElement private videoFiles: VideoFile[] private torrent: WebTorrent.Torrent + private autoplay = false constructor (player: videojs.Player, options: PeertubePluginOptions) { super(player, options) + // Fix canplay event on google chrome by disabling default videojs autoplay + this.autoplay = this.player.options_.autoplay + this.player.options_.autoplay = false + this.videoFiles = options.videoFiles // Hack to "simulate" src link in video.js >= 6 @@ -281,6 +286,7 @@ class PeerTubePlugin extends Plugin { this.renderer = renderer if (!this.player.paused()) this.player.play().then(done) + else done() }) }) @@ -349,18 +355,12 @@ class PeerTubePlugin extends Plugin { const webTorrentButton = new WebTorrentButton(this.player) controlBar.webTorrent = controlBar.el().insertBefore(webTorrentButton.el(), controlBar.progressControl.el()) - if (this.player.options_.autoplay === true) { - this.updateVideoFile() + if (this.autoplay === true) { + this.updateVideoFile(undefined, () => this.player.play()) } else { this.player.one('play', () => { - // On firefox, we need to wait to load the video before playing - if (navigator.userAgent.toLowerCase().indexOf('firefox') !== -1) { - this.player.pause() - this.updateVideoFile(undefined, () => this.player.play()) - return - } - - this.updateVideoFile(undefined) + this.player.pause() + this.updateVideoFile(undefined, () => this.player.play()) }) } }