aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone')
-rw-r--r--client/src/standalone/videos/embed.ts44
1 files changed, 22 insertions, 22 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 5213443fc..e3bcbc010 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -1,15 +1,11 @@
1import './embed.scss' 1import './embed.scss'
2 2
3import { 3import {
4 getCompleteLocale,
5 is18nLocale,
6 isDefaultLocale,
7 peertubeTranslate, 4 peertubeTranslate,
8 ResultList, 5 ResultList,
9 ServerConfig, 6 ServerConfig,
10 VideoDetails 7 VideoDetails
11} from '../../../../shared' 8} from '../../../../shared'
12import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
13import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' 9import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model'
14import { 10import {
15 P2PMediaLoaderOptions, 11 P2PMediaLoaderOptions,
@@ -19,10 +15,14 @@ import {
19import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' 15import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
20import { PeerTubeEmbedApi } from './embed-api' 16import { PeerTubeEmbedApi } from './embed-api'
21import { TranslationsManager } from '../../assets/player/translations-manager' 17import { TranslationsManager } from '../../assets/player/translations-manager'
18import { VideoJsPlayer } from 'video.js'
19import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
20
21type Translations = { [ id: string ]: string }
22 22
23export class PeerTubeEmbed { 23export class PeerTubeEmbed {
24 videoElement: HTMLVideoElement 24 videoElement: HTMLVideoElement
25 player: any 25 player: VideoJsPlayer
26 api: PeerTubeEmbedApi = null 26 api: PeerTubeEmbedApi = null
27 autoplay: boolean 27 autoplay: boolean
28 controls: boolean 28 controls: boolean
@@ -71,7 +71,7 @@ export class PeerTubeEmbed {
71 element.parentElement.removeChild(element) 71 element.parentElement.removeChild(element)
72 } 72 }
73 73
74 displayError (text: string, translations?: { [ id: string ]: string }) { 74 displayError (text: string, translations?: Translations) {
75 // Remove video element 75 // Remove video element
76 if (this.videoElement) this.removeElement(this.videoElement) 76 if (this.videoElement) this.removeElement(this.videoElement)
77 77
@@ -90,12 +90,12 @@ export class PeerTubeEmbed {
90 errorText.innerHTML = translatedText 90 errorText.innerHTML = translatedText
91 } 91 }
92 92
93 videoNotFound (translations?: { [ id: string ]: string }) { 93 videoNotFound (translations?: Translations) {
94 const text = 'This video does not exist.' 94 const text = 'This video does not exist.'
95 this.displayError(text, translations) 95 this.displayError(text, translations)
96 } 96 }
97 97
98 videoFetchError (translations?: { [ id: string ]: string }) { 98 videoFetchError (translations?: Translations) {
99 const text = 'We cannot fetch the video. Please try again later.' 99 const text = 'We cannot fetch the video. Please try again later.'
100 this.displayError(text, translations) 100 this.displayError(text, translations)
101 } 101 }
@@ -237,7 +237,7 @@ export class PeerTubeEmbed {
237 }) 237 })
238 } 238 }
239 239
240 this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: any) => this.player = player) 240 this.player = await PeertubePlayerManager.initialize(this.mode, options, (player: VideoJsPlayer) => this.player = player)
241 this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations)) 241 this.player.on('customError', (event: any, data: any) => this.handleError(data.err, serverTranslations))
242 242
243 window[ 'videojsPlayer' ] = this.player 243 window[ 'videojsPlayer' ] = this.player
@@ -261,22 +261,22 @@ export class PeerTubeEmbed {
261 } 261 }
262 262
263 private async buildDock (videoInfo: VideoDetails, configResponse: Response) { 263 private async buildDock (videoInfo: VideoDetails, configResponse: Response) {
264 if (this.controls) { 264 if (!this.controls) return
265 // On webtorrent fallback, player may have been disposed
266 if (!this.player.player_) return
267 265
268 const title = this.title ? videoInfo.name : undefined 266 // On webtorrent fallback, player may have been disposed
267 if (!this.player.player_) return
269 268
270 const config: ServerConfig = await configResponse.json() 269 const title = this.title ? videoInfo.name : undefined
271 const description = config.tracker.enabled && this.warningTitle
272 ? '<span class="text">' + this.player.localize('Watching this video may reveal your IP address to others.') + '</span>'
273 : undefined
274 270
275 this.player.dock({ 271 const config: ServerConfig = await configResponse.json()
276 title, 272 const description = config.tracker.enabled && this.warningTitle
277 description 273 ? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
278 }) 274 : undefined
279 } 275
276 this.player.dock({
277 title,
278 description
279 })
280 } 280 }
281 281
282 private buildCSS () { 282 private buildCSS () {