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'
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',
playerElement: HTMLVideoElement
userRating: UserVideoRateType = null
video: VideoDetails = null
- videoNotFound = false
descriptionLoading = false
completeDescriptionShown = false
likesBarTooltipText = ''
hasAlreadyAcceptedPrivacyConcern = false
+ private videojsLocaleLoaded = false
private otherVideos: Video[] = []
private paramsSub: Subscription
private markdownService: MarkdownService,
private zone: NgZone,
private redirectService: RedirectService,
- private i18n: I18n
+ private i18n: I18n,
+ @Inject(LOCALE_ID) private localeId: string
) {}
get user () {
const startTime = this.route.snapshot.queryParams.start
this.onVideoFetched(video, startTime)
.catch(err => this.handleError(err))
- },
-
- error => {
- this.videoNotFound = true
- console.error(error)
}
)
})
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()
},
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.
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 }
)
}
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)
})
})