]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/standalone/videos/embed.ts
Fix users tests
[github/Chocobozzz/PeerTube.git] / client / src / standalone / videos / embed.ts
index d5b42a0259d065ac06423ddd527e5adb578f18b8..286757e5e0022bb9958017a547d520ef16987bbf 100644 (file)
@@ -15,14 +15,14 @@ import {
 import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
 import { PeerTubeEmbedApi } from './embed-api'
 import { TranslationsManager } from '../../assets/player/translations-manager'
-import { VideoJsPlayer } from 'video.js'
+import videojs from 'video.js'
 import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
 
 type Translations = { [ id: string ]: string }
 
 export class PeerTubeEmbed {
   videoElement: HTMLVideoElement
-  player: VideoJsPlayer
+  player: videojs.Player
   api: PeerTubeEmbedApi = null
   autoplay: boolean
   controls: boolean
@@ -129,7 +129,7 @@ export class PeerTubeEmbed {
 
       this.autoplay = this.getParamToggle(params, 'autoplay', false)
       this.controls = this.getParamToggle(params, 'controls', true)
-      this.muted = this.getParamToggle(params, 'muted', false)
+      this.muted = this.getParamToggle(params, 'muted', undefined)
       this.loop = this.getParamToggle(params, 'loop', false)
       this.title = this.getParamToggle(params, 'title', true)
       this.enableApi = this.getParamToggle(params, 'api', this.enableApi)
@@ -237,7 +237,7 @@ export class PeerTubeEmbed {
       })
     }
 
-    this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: VideoJsPlayer) => this.player = player)
+    this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: videojs.Player) => this.player = player)
     this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations))
 
     window[ 'videojsPlayer' ] = this.player
@@ -263,6 +263,9 @@ export class PeerTubeEmbed {
   private async buildDock (videoInfo: VideoDetails, configResponse: Response) {
     if (!this.controls) return
 
+    // On webtorrent fallback, player may have been disposed
+    if (!this.player.player_) return
+
     const title = this.title ? videoInfo.name : undefined
 
     const config: ServerConfig = await configResponse.json()