]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/video-watch.component.ts
Fix import with when the imported file has the same extension than an
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / video-watch.component.ts
index f3b4f7a2b0b6d5851634f08f69ef02f619377c7a..eefa43a73bde51ae4d543e1ccc7cd7627dbd4a51 100644 (file)
@@ -1,5 +1,5 @@
 import { catchError } from 'rxjs/operators'
-import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
+import { Component, ElementRef, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild, Inject } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { RedirectService } from '@app/core/routing/redirect.service'
 import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
@@ -21,9 +21,11 @@ import { MarkdownService } from '../shared'
 import { VideoDownloadComponent } from './modal/video-download.component'
 import { VideoReportComponent } from './modal/video-report.component'
 import { VideoShareComponent } from './modal/video-share.component'
-import { getVideojsOptions } from '../../../assets/player/peertube-player'
+import { getVideojsOptions, loadLocale, addContextMenu } from '../../../assets/player/peertube-player'
 import { ServerService } from '@app/core'
 import { I18n } from '@ngx-translate/i18n-polyfill'
+import { environment } from '../../../environments/environment'
+import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
 
 @Component({
   selector: 'my-video-watch',
@@ -44,7 +46,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   playerElement: HTMLVideoElement
   userRating: UserVideoRateType = null
   video: VideoDetails = null
-  videoNotFound = false
   descriptionLoading = false
 
   completeDescriptionShown = false
@@ -54,6 +55,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   likesBarTooltipText = ''
   hasAlreadyAcceptedPrivacyConcern = false
 
+  private videojsLocaleLoaded = false
   private otherVideos: Video[] = []
   private paramsSub: Subscription
 
@@ -72,7 +74,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     private markdownService: MarkdownService,
     private zone: NgZone,
     private redirectService: RedirectService,
-    private i18n: I18n
+    private i18n: I18n,
+    @Inject(LOCALE_ID) private localeId: string
   ) {}
 
   get user () {
@@ -115,11 +118,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
               const startTime = this.route.snapshot.queryParams.start
               this.onVideoFetched(video, startTime)
                   .catch(err => this.handleError(err))
-            },
-
-            error => {
-              this.videoNotFound = true
-              console.error(error)
             }
           )
     })
@@ -163,7 +161,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
                                 status => {
                                   this.notificationsService.success(
                                     this.i18n('Success'),
-                                    this.i18n('Video {{ videoName }} had been blacklisted.', { videoName: this.video.name })
+                                    this.i18n('Video {{videoName}} had been blacklisted.', { videoName: this.video.name })
                                   )
                                   this.redirectService.redirectToHomepage()
                                 },
@@ -265,7 +263,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
         status => {
           this.notificationsService.success(
             this.i18n('Success'),
-            this.i18n('Video {{ videoName }} deleted.', { videoName: this.video.name })
+            this.i18n('Video {{videoName}} deleted.', { videoName: this.video.name })
           )
 
           // Go back to the video-list.
@@ -297,8 +295,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
   private setVideoLikesBarTooltipText () {
     this.likesBarTooltipText = this.i18n(
-      '{{ likesNumber }} likes / {{ dislikesNumber }} dislikes',
-      { likesNumber: this.video.likes, dislikes: this.video.dislikes }
+      '{{likesNumber}} likes / {{dislikesNumber}} dislikes',
+      { likesNumber: this.video.likes, dislikesNumber: this.video.dislikes }
     )
   }
 
@@ -365,20 +363,27 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
       inactivityTimeout: 2500,
       videoFiles: this.video.files,
       playerElement: this.playerElement,
-      videoEmbedUrl: this.video.embedUrl,
       videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid),
       videoDuration: this.video.duration,
       enableHotkeys: true,
       peertubeLink: false,
       poster: this.video.previewUrl,
-      startTime
+      startTime,
+      theaterMode: true
     })
 
+    if (this.videojsLocaleLoaded === false) {
+      await loadLocale(environment.apiUrl, videojs, isOnDevLocale() ? getDevLocale() : this.localeId)
+      this.videojsLocaleLoaded = true
+    }
+
     const self = this
-    this.zone.runOutsideAngular(() => {
+    this.zone.runOutsideAngular(async () => {
       videojs(this.playerElement, videojsOptions, function () {
         self.player = this
         this.on('customError', (event, data) => self.handleError(data.err))
+
+        addContextMenu(self.player, self.video.embedUrl)
       })
     })