diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 23d74494c..d3e16c4cf 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError } from 'rxjs/operators' |
2 | import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, ElementRef, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild, Inject } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { RedirectService } from '@app/core/routing/redirect.service' | 4 | import { RedirectService } from '@app/core/routing/redirect.service' |
5 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | 5 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' |
@@ -21,9 +21,10 @@ import { MarkdownService } from '../shared' | |||
21 | import { VideoDownloadComponent } from './modal/video-download.component' | 21 | import { VideoDownloadComponent } from './modal/video-download.component' |
22 | import { VideoReportComponent } from './modal/video-report.component' | 22 | import { VideoReportComponent } from './modal/video-report.component' |
23 | import { VideoShareComponent } from './modal/video-share.component' | 23 | import { VideoShareComponent } from './modal/video-share.component' |
24 | import { getVideojsOptions } from '../../../assets/player/peertube-player' | 24 | import { getVideojsOptions, loadLocale, addContextMenu } from '../../../assets/player/peertube-player' |
25 | import { ServerService } from '@app/core' | 25 | import { ServerService } from '@app/core' |
26 | import { I18n } from '@ngx-translate/i18n-polyfill' | 26 | import { I18n } from '@ngx-translate/i18n-polyfill' |
27 | import { environment } from '../../../environments/environment' | ||
27 | 28 | ||
28 | @Component({ | 29 | @Component({ |
29 | selector: 'my-video-watch', | 30 | selector: 'my-video-watch', |
@@ -54,6 +55,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
54 | likesBarTooltipText = '' | 55 | likesBarTooltipText = '' |
55 | hasAlreadyAcceptedPrivacyConcern = false | 56 | hasAlreadyAcceptedPrivacyConcern = false |
56 | 57 | ||
58 | private videojsLocaleLoaded = false | ||
57 | private otherVideos: Video[] = [] | 59 | private otherVideos: Video[] = [] |
58 | private paramsSub: Subscription | 60 | private paramsSub: Subscription |
59 | 61 | ||
@@ -72,7 +74,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
72 | private markdownService: MarkdownService, | 74 | private markdownService: MarkdownService, |
73 | private zone: NgZone, | 75 | private zone: NgZone, |
74 | private redirectService: RedirectService, | 76 | private redirectService: RedirectService, |
75 | private i18n: I18n | 77 | private i18n: I18n, |
78 | @Inject(LOCALE_ID) private localeId: string | ||
76 | ) {} | 79 | ) {} |
77 | 80 | ||
78 | get user () { | 81 | get user () { |
@@ -365,7 +368,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
365 | inactivityTimeout: 2500, | 368 | inactivityTimeout: 2500, |
366 | videoFiles: this.video.files, | 369 | videoFiles: this.video.files, |
367 | playerElement: this.playerElement, | 370 | playerElement: this.playerElement, |
368 | videoEmbedUrl: this.video.embedUrl, | ||
369 | videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid), | 371 | videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid), |
370 | videoDuration: this.video.duration, | 372 | videoDuration: this.video.duration, |
371 | enableHotkeys: true, | 373 | enableHotkeys: true, |
@@ -374,11 +376,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
374 | startTime | 376 | startTime |
375 | }) | 377 | }) |
376 | 378 | ||
379 | if (this.videojsLocaleLoaded === false) { | ||
380 | await loadLocale(environment.apiUrl, videojs, environment.production === true ? this.localeId : 'fr') | ||
381 | this.videojsLocaleLoaded = true | ||
382 | } | ||
383 | |||
377 | const self = this | 384 | const self = this |
378 | this.zone.runOutsideAngular(() => { | 385 | this.zone.runOutsideAngular(async () => { |
379 | videojs(this.playerElement, videojsOptions, function () { | 386 | videojs(this.playerElement, videojsOptions, function () { |
380 | self.player = this | 387 | self.player = this |
381 | this.on('customError', (event, data) => self.handleError(data.err)) | 388 | this.on('customError', (event, data) => self.handleError(data.err)) |
389 | |||
390 | addContextMenu(self.player, self.video.embedUrl) | ||
382 | }) | 391 | }) |
383 | }) | 392 | }) |
384 | 393 | ||