1 import { Hotkey, HotkeysService } from 'angular2-hotkeys'
2 import { forkJoin, Observable, Subscription } from 'rxjs'
3 import { catchError } from 'rxjs/operators'
4 import { PlatformLocation } from '@angular/common'
5 import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
6 import { ActivatedRoute, Router } from '@angular/router'
18 import { HooksService } from '@app/core/plugins/hooks.service'
19 import { RedirectService } from '@app/core/routing/redirect.service'
20 import { isXPercentInViewport, scrollToTop } from '@app/helpers'
21 import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
22 import { VideoShareComponent } from '@app/shared/shared-share-modal'
23 import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
24 import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/shared-video-miniature'
25 import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
26 import { MetaService } from '@ngx-meta/core'
27 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
28 import { ServerConfig, ServerErrorCode, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
29 import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage'
32 P2PMediaLoaderOptions,
33 PeertubePlayerManager,
34 PeertubePlayerManagerOptions,
37 } from '../../../assets/player/peertube-player-manager'
38 import { isWebRTCDisabled, timeToInt } from '../../../assets/player/utils'
39 import { environment } from '../../../environments/environment'
40 import { VideoSupportComponent } from './modal/video-support.component'
41 import { VideoWatchPlaylistComponent } from './video-watch-playlist.component'
43 type URLOptions = CustomizationOptions & { playerMode: PlayerMode }
46 selector: 'my-video-watch',
47 templateUrl: './video-watch.component.html',
48 styleUrls: [ './video-watch.component.scss' ]
50 export class VideoWatchComponent implements OnInit, OnDestroy {
51 private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
53 @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent
54 @ViewChild('videoShareModal') videoShareModal: VideoShareComponent
55 @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent
56 @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
57 @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent
60 playerElement: HTMLVideoElement
61 theaterEnabled = false
62 userRating: UserVideoRateType = null
63 descriptionLoading = false
65 video: VideoDetails = null
66 videoCaptions: VideoCaption[] = []
68 playlistPosition: number
69 playlist: VideoPlaylist = null
71 completeDescriptionShown = false
72 completeVideoDescription: string
73 shortVideoDescription: string
74 videoHTMLDescription = ''
75 likesBarTooltipText = ''
76 hasAlreadyAcceptedPrivacyConcern = false
77 remoteServerDown = false
78 hotkeys: Hotkey[] = []
83 tooltipSaveToPlaylist = ''
85 videoActionsOptions: VideoActionsDisplayType = {
97 private nextVideoUuid = ''
98 private nextVideoTitle = ''
99 private currentTime: number
100 private paramsSub: Subscription
101 private queryParamsSub: Subscription
102 private configSub: Subscription
103 private liveVideosSub: Subscription
105 private serverConfig: ServerConfig
108 private elementRef: ElementRef,
109 private changeDetector: ChangeDetectorRef,
110 private route: ActivatedRoute,
111 private router: Router,
112 private videoService: VideoService,
113 private playlistService: VideoPlaylistService,
114 private confirmService: ConfirmService,
115 private metaService: MetaService,
116 private authService: AuthService,
117 private userService: UserService,
118 private serverService: ServerService,
119 private restExtractor: RestExtractor,
120 private notifier: Notifier,
121 private markdownService: MarkdownService,
122 private zone: NgZone,
123 private redirectService: RedirectService,
124 private videoCaptionService: VideoCaptionService,
125 private hotkeysService: HotkeysService,
126 private hooks: HooksService,
127 private peertubeSocket: PeerTubeSocket,
128 private location: PlatformLocation,
129 @Inject(LOCALE_ID) private localeId: string
131 this.tooltipLike = $localize`Like this video`
132 this.tooltipDislike = $localize`Dislike this video`
133 this.tooltipSupport = $localize`Support options for this video`
134 this.tooltipSaveToPlaylist = $localize`Save to playlist`
138 return this.authService.getUser()
141 get anonymousUser () {
142 return this.userService.getAnonymousUser()
146 PeertubePlayerManager.initState()
148 this.serverConfig = this.serverService.getTmpConfig()
150 this.configSub = this.serverService.getConfig()
151 .subscribe(config => {
152 this.serverConfig = config
155 isWebRTCDisabled() ||
156 this.serverConfig.tracker.enabled === false ||
157 getStoredP2PEnabled() === false ||
158 peertubeLocalStorage.getItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
160 this.hasAlreadyAcceptedPrivacyConcern = true
164 this.paramsSub = this.route.params.subscribe(routeParams => {
165 const videoId = routeParams[ 'videoId' ]
166 if (videoId) this.loadVideo(videoId)
168 const playlistId = routeParams[ 'playlistId' ]
169 if (playlistId) this.loadPlaylist(playlistId)
172 this.queryParamsSub = this.route.queryParams.subscribe(queryParams => {
173 this.playlistPosition = queryParams[ 'playlistPosition' ]
174 this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition)
176 const start = queryParams[ 'start' ]
177 if (this.player && start) this.player.currentTime(parseInt(start, 10))
182 this.theaterEnabled = getStoredTheater()
184 this.hooks.runAction('action:video-watch.init', 'video-watch')
190 // Unsubscribe subscriptions
191 if (this.paramsSub) this.paramsSub.unsubscribe()
192 if (this.queryParamsSub) this.queryParamsSub.unsubscribe()
193 if (this.configSub) this.configSub.unsubscribe()
194 if (this.liveVideosSub) this.liveVideosSub.unsubscribe()
197 this.hotkeysService.remove(this.hotkeys)
201 if (this.isUserLoggedIn() === false) return
203 // Already liked this video
204 if (this.userRating === 'like') this.setRating('none')
205 else this.setRating('like')
209 if (this.isUserLoggedIn() === false) return
211 // Already disliked this video
212 if (this.userRating === 'dislike') this.setRating('none')
213 else this.setRating('dislike')
216 getRatePopoverText () {
217 if (this.isUserLoggedIn()) return undefined
219 return $localize`You need to be <a href="/login">logged in</a> to rate this video.`
222 showMoreDescription () {
223 if (this.completeVideoDescription === undefined) {
224 return this.loadCompleteDescription()
227 this.updateVideoDescription(this.completeVideoDescription)
228 this.completeDescriptionShown = true
231 showLessDescription () {
232 this.updateVideoDescription(this.shortVideoDescription)
233 this.completeDescriptionShown = false
236 showDownloadModal () {
237 this.videoDownloadModal.show(this.video, this.videoCaptions)
240 isVideoDownloadable () {
241 return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled && !this.video.isLive
244 loadCompleteDescription () {
245 this.descriptionLoading = true
247 this.videoService.loadCompleteDescription(this.video.descriptionPath)
250 this.completeDescriptionShown = true
251 this.descriptionLoading = false
253 this.shortVideoDescription = this.video.description
254 this.completeVideoDescription = description
256 this.updateVideoDescription(this.completeVideoDescription)
260 this.descriptionLoading = false
261 this.notifier.error(error.message)
266 showSupportModal () {
267 // Check video was playing before opening support modal
268 const isVideoPlaying = this.isPlaying()
272 const modalRef = this.videoSupportModal.show()
274 modalRef.result.then(() => {
275 if (isVideoPlaying) {
284 this.videoShareModal.show(this.currentTime, this.videoWatchPlaylist.currentPlaylistPosition)
288 return this.authService.isLoggedIn()
292 if (!this.video || Array.isArray(this.video.tags) === false) return []
294 return this.video.tags
297 onRecommendations (videos: Video[]) {
298 if (videos.length > 0) {
299 // The recommended videos's first element should be the next video
300 const video = videos[0]
301 this.nextVideoUuid = video.uuid
302 this.nextVideoTitle = video.name
311 this.redirectService.redirectToHomepage()
314 declinedPrivacyConcern () {
315 peertubeLocalStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false')
316 this.hasAlreadyAcceptedPrivacyConcern = false
319 acceptedPrivacyConcern () {
320 peertubeLocalStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
321 this.hasAlreadyAcceptedPrivacyConcern = true
324 isVideoToTranscode () {
325 return this.video && this.video.state.id === VideoState.TO_TRANSCODE
329 return this.video && this.video.state.id === VideoState.TO_IMPORT
332 hasVideoScheduledPublication () {
333 return this.video && this.video.scheduledUpdate !== undefined
337 return !!(this.video?.isLive)
340 isWaitingForLive () {
341 return this.video?.state.id === VideoState.WAITING_FOR_LIVE
345 return this.video?.state.id === VideoState.LIVE_ENDED
348 isVideoBlur (video: Video) {
349 return video.isVideoNSFWForUser(this.user, this.serverConfig)
352 isAutoPlayEnabled () {
354 (this.user && this.user.autoPlayNextVideo) ||
355 this.anonymousUser.autoPlayNextVideo
359 handleTimestampClicked (timestamp: number) {
360 if (this.player) this.player.currentTime(timestamp)
364 isPlaylistAutoPlayEnabled () {
366 (this.user && this.user.autoPlayNextVideoPlaylist) ||
367 this.anonymousUser.autoPlayNextVideoPlaylist
371 isChannelDisplayNameGeneric () {
372 const genericChannelDisplayName = [
373 `Main ${this.video.channel.ownerAccount.name} channel`,
374 `Default ${this.video.channel.ownerAccount.name} channel`
377 return genericChannelDisplayName.includes(this.video.channel.displayName)
380 onPlaylistVideoFound (videoId: string) {
381 this.loadVideo(videoId)
384 private loadVideo (videoId: string) {
385 // Video did not change
386 if (this.video && this.video.uuid === videoId) return
388 if (this.player) this.player.pause()
390 const videoObs = this.hooks.wrapObsFun(
391 this.videoService.getVideo.bind(this.videoService),
394 'filter:api.video-watch.video.get.params',
395 'filter:api.video-watch.video.get.result'
401 this.videoCaptionService.listCaptions(videoId)
404 // If 401, the video is private or blocked so redirect to 404
406 if (err.body.errorCode === ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS && err.body.originUrl) {
407 const search = window.location.search
408 let originUrl = err.body.originUrl
409 if (search) originUrl += search
411 this.confirmService.confirm(
412 $localize`This video is not available on this instance. Do you want to be redirected on the origin instance: <a href="${originUrl}">${originUrl}</a>?`,
413 $localize`Redirection`
415 if (res === false) return this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])
417 return window.location.href = originUrl
421 return this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])
424 .subscribe(([ video, captionsResult ]) => {
425 const queryParams = this.route.snapshot.queryParams
428 resume: queryParams.resume,
430 startTime: queryParams.start,
431 stopTime: queryParams.stop,
433 muted: queryParams.muted,
434 loop: queryParams.loop,
435 subtitle: queryParams.subtitle,
437 playerMode: queryParams.mode,
441 this.onVideoFetched(video, captionsResult.data, urlOptions)
442 .catch(err => this.handleError(err))
446 private loadPlaylist (playlistId: string) {
447 // Playlist did not change
448 if (this.playlist && this.playlist.uuid === playlistId) return
450 this.playlistService.getVideoPlaylist(playlistId)
452 // If 401, the video is private or blocked so redirect to 404
453 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
455 .subscribe(playlist => {
456 this.playlist = playlist
458 this.videoWatchPlaylist.loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition)
462 private updateVideoDescription (description: string) {
463 this.video.description = description
464 this.setVideoDescriptionHTML()
465 .catch(err => console.error(err))
468 private async setVideoDescriptionHTML () {
469 const html = await this.markdownService.textMarkdownToHTML(this.video.description)
470 this.videoHTMLDescription = await this.markdownService.processVideoTimestamps(html)
473 private setVideoLikesBarTooltipText () {
474 this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes`
477 private handleError (err: any) {
478 const errorMessage: string = typeof err === 'string' ? err : err.message
479 if (!errorMessage) return
481 // Display a message in the video player instead of a notification
482 if (errorMessage.indexOf('from xs param') !== -1) {
484 this.remoteServerDown = true
485 this.changeDetector.detectChanges()
490 this.notifier.error(errorMessage)
493 private checkUserRating () {
494 // Unlogged users do not have ratings
495 if (this.isUserLoggedIn() === false) return
497 this.videoService.getUserVideoRating(this.video.id)
501 this.userRating = ratingObject.rating
505 err => this.notifier.error(err.message)
509 private async onVideoFetched (
511 videoCaptions: VideoCaption[],
512 urlOptions: URLOptions
514 this.subscribeToLiveEventsIfNeeded(this.video, video)
517 this.videoCaptions = videoCaptions
519 // Re init attributes
520 this.descriptionLoading = false
521 this.completeDescriptionShown = false
522 this.remoteServerDown = false
523 this.currentTime = undefined
525 if (this.isVideoBlur(this.video)) {
526 const res = await this.confirmService.confirm(
527 $localize`This video contains mature or explicit content. Are you sure you want to watch it?`,
528 $localize`Mature or explicit content`
530 if (res === false) return this.location.back()
533 const videoState = this.video.state.id
534 if (videoState === VideoState.LIVE_ENDED || videoState === VideoState.WAITING_FOR_LIVE) return
536 // Flush old player if needed
539 // Build video element, because videojs removes it on dispose
540 const playerElementWrapper = this.elementRef.nativeElement.querySelector('#videojs-wrapper')
541 this.playerElement = document.createElement('video')
542 this.playerElement.className = 'video-js vjs-peertube-skin'
543 this.playerElement.setAttribute('playsinline', 'true')
544 playerElementWrapper.appendChild(this.playerElement)
552 const { playerMode, playerOptions } = await this.hooks.wrapFun(
553 this.buildPlayerManagerOptions.bind(this),
556 'filter:internal.video-watch.player.build-options.params',
557 'filter:internal.video-watch.player.build-options.result'
560 this.zone.runOutsideAngular(async () => {
561 this.player = await PeertubePlayerManager.initialize(playerMode, playerOptions, player => this.player = player)
563 this.player.on('customError', ({ err }: { err: any }) => this.handleError(err))
565 this.player.on('timeupdate', () => {
566 this.currentTime = Math.floor(this.player.currentTime())
570 * replaces this.player.one('ended')
571 * 'condition()': true to make the upnext functionality trigger,
572 * false to disable the upnext functionality
573 * go to the next video in 'condition()' if you don't want of the timer.
574 * 'next': function triggered at the end of the timer.
575 * 'suspended': function used at each clic of the timer checking if we need
576 * to reset progress and wait until 'suspended' becomes truthy again.
579 timeout: 10000, // 10s
580 headText: $localize`Up Next`,
581 cancelText: $localize`Cancel`,
582 suspendedText: $localize`Autoplay is suspended`,
583 getTitle: () => this.nextVideoTitle,
584 next: () => this.zone.run(() => this.autoplayNext()),
587 if (this.isPlaylistAutoPlayEnabled()) {
588 // upnext will not trigger, and instead the next video will play immediately
589 this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
591 } else if (this.isAutoPlayEnabled()) {
592 return true // upnext will trigger
594 return false // upnext will not trigger, and instead leave the video stopping
598 !isXPercentInViewport(this.player.el(), 80) ||
599 !document.getElementById('content').contains(document.activeElement)
604 this.player.one('stopped', () => {
606 if (this.isPlaylistAutoPlayEnabled()) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
610 this.player.one('ended', () => {
611 if (this.video.isLive) {
612 this.video.state.id = VideoState.LIVE_ENDED
616 this.player.on('theaterChange', (_: any, enabled: boolean) => {
617 this.zone.run(() => this.theaterEnabled = enabled)
620 this.hooks.runAction('action:video-watch.player.loaded', 'video-watch', { player: this.player, videojs, video: this.video })
623 this.setVideoDescriptionHTML()
624 this.setVideoLikesBarTooltipText()
626 this.setOpenGraphTags()
627 this.checkUserRating()
629 this.hooks.runAction('action:video-watch.video.loaded', 'video-watch', { videojs })
632 private autoplayNext () {
634 this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
635 } else if (this.nextVideoUuid) {
636 this.router.navigate([ '/videos/watch', this.nextVideoUuid ])
640 private setRating (nextRating: UserVideoRateType) {
641 const ratingMethods: { [id in UserVideoRateType]: (id: number) => Observable<any> } = {
642 like: this.videoService.setVideoLike,
643 dislike: this.videoService.setVideoDislike,
644 none: this.videoService.unsetVideoLike
647 ratingMethods[nextRating].call(this.videoService, this.video.id)
650 // Update the video like attribute
651 this.updateVideoRating(this.userRating, nextRating)
652 this.userRating = nextRating
655 (err: { message: string }) => this.notifier.error(err.message)
659 private updateVideoRating (oldRating: UserVideoRateType, newRating: UserVideoRateType) {
660 let likesToIncrement = 0
661 let dislikesToIncrement = 0
664 if (oldRating === 'like') likesToIncrement--
665 if (oldRating === 'dislike') dislikesToIncrement--
668 if (newRating === 'like') likesToIncrement++
669 if (newRating === 'dislike') dislikesToIncrement++
671 this.video.likes += likesToIncrement
672 this.video.dislikes += dislikesToIncrement
674 this.video.buildLikeAndDislikePercents()
675 this.setVideoLikesBarTooltipText()
678 private setOpenGraphTags () {
679 this.metaService.setTitle(this.video.name)
681 this.metaService.setTag('og:type', 'video')
683 this.metaService.setTag('og:title', this.video.name)
684 this.metaService.setTag('name', this.video.name)
686 this.metaService.setTag('og:description', this.video.description)
687 this.metaService.setTag('description', this.video.description)
689 this.metaService.setTag('og:image', this.video.previewPath)
691 this.metaService.setTag('og:duration', this.video.duration.toString())
693 this.metaService.setTag('og:site_name', 'PeerTube')
695 this.metaService.setTag('og:url', window.location.href)
696 this.metaService.setTag('url', window.location.href)
699 private isAutoplay () {
700 // We'll jump to the thread id, so do not play the video
701 if (this.route.snapshot.params['threadId']) return false
703 // Otherwise true by default
704 if (!this.user) return true
706 // Be sure the autoPlay is set to false
707 return this.user.autoPlayVideo !== false
710 private flushPlayer () {
711 // Remove player if it exists
714 this.player.dispose()
715 this.player = undefined
717 console.error('Cannot dispose player.', err)
722 private buildPlayerManagerOptions (params: {
724 videoCaptions: VideoCaption[],
725 urlOptions: CustomizationOptions & { playerMode: PlayerMode },
728 const { video, videoCaptions, urlOptions, user } = params
729 const getStartTime = () => {
730 const byUrl = urlOptions.startTime !== undefined
731 const byHistory = video.userHistory && (!this.playlist || urlOptions.resume !== undefined)
733 if (byUrl) return timeToInt(urlOptions.startTime)
734 if (byHistory) return video.userHistory.currentTime
739 let startTime = getStartTime()
741 // If we are at the end of the video, reset the timer
742 if (video.duration - startTime <= 1) startTime = 0
744 const playerCaptions = videoCaptions.map(c => ({
745 label: c.language.label,
746 language: c.language.id,
747 src: environment.apiUrl + c.captionPath
750 const options: PeertubePlayerManagerOptions = {
752 autoplay: this.isAutoplay(),
753 nextVideo: () => this.zone.run(() => this.autoplayNext()),
755 playerElement: this.playerElement,
756 onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,
758 videoDuration: video.duration,
760 inactivityTimeout: 2500,
761 poster: video.previewUrl,
764 stopTime: urlOptions.stopTime,
765 controls: urlOptions.controls,
766 muted: urlOptions.muted,
767 loop: urlOptions.loop,
768 subtitle: urlOptions.subtitle,
770 peertubeLink: urlOptions.peertubeLink,
773 captions: videoCaptions.length !== 0,
775 videoViewUrl: video.privacy.id !== VideoPrivacy.PRIVATE
776 ? this.videoService.getVideoViewUrl(video.uuid)
778 embedUrl: video.embedUrl,
780 isLive: video.isLive,
782 language: this.localeId,
784 userWatching: user && user.videosHistoryEnabled === true ? {
785 url: this.videoService.getUserWatchingVideoUrl(video.uuid),
786 authorizationHeader: this.authService.getRequestHeaderValue()
789 serverUrl: environment.apiUrl,
791 videoCaptions: playerCaptions
795 videoFiles: video.files
801 if (urlOptions.playerMode) {
802 if (urlOptions.playerMode === 'p2p-media-loader') mode = 'p2p-media-loader'
803 else mode = 'webtorrent'
805 if (video.hasHlsPlaylist()) mode = 'p2p-media-loader'
806 else mode = 'webtorrent'
809 // p2p-media-loader needs TextEncoder, try to fallback on WebTorrent
810 if (typeof TextEncoder === 'undefined') {
814 if (mode === 'p2p-media-loader') {
815 const hlsPlaylist = video.getHlsPlaylist()
817 const p2pMediaLoader = {
818 playlistUrl: hlsPlaylist.playlistUrl,
819 segmentsSha256Url: hlsPlaylist.segmentsSha256Url,
820 redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl),
821 trackerAnnounce: video.trackerUrls,
822 videoFiles: hlsPlaylist.files
823 } as P2PMediaLoaderOptions
825 Object.assign(options, { p2pMediaLoader })
828 return { playerMode: mode, playerOptions: options }
831 private pausePlayer () {
832 if (!this.player) return
837 private resumePlayer () {
838 if (!this.player) return
843 private isPlaying () {
844 if (!this.player) return
846 return !this.player.paused()
849 private async subscribeToLiveEventsIfNeeded (oldVideo: VideoDetails, newVideo: VideoDetails) {
850 if (!this.liveVideosSub) {
851 this.liveVideosSub = this.peertubeSocket.getLiveVideosObservable()
852 .subscribe(({ payload }) => {
853 if (payload.state !== VideoState.PUBLISHED) return
855 const videoState = this.video.state.id
856 if (videoState !== VideoState.WAITING_FOR_LIVE && videoState !== VideoState.LIVE_ENDED) return
858 console.log('Loading video after live update.')
860 const videoUUID = this.video.uuid
862 // Reset to refetch the video
863 this.video = undefined
864 this.loadVideo(videoUUID)
868 if (oldVideo && oldVideo.id !== newVideo.id) {
869 await this.peertubeSocket.unsubscribeLiveVideos(oldVideo.id)
872 if (!newVideo.isLive) return
874 await this.peertubeSocket.subscribeToLiveVideosSocket(newVideo.id)
877 private initHotkeys () {
879 // These hotkeys are managed by the player
880 new Hotkey('f', e => e, undefined, $localize`Enter/exit fullscreen (requires player focus)`),
881 new Hotkey('space', e => e, undefined, $localize`Play/Pause the video (requires player focus)`),
882 new Hotkey('m', e => e, undefined, $localize`Mute/unmute the video (requires player focus)`),
884 new Hotkey('0-9', e => e, undefined, $localize`Skip to a percentage of the video: 0 is 0% and 9 is 90% (requires player focus)`),
886 new Hotkey('up', e => e, undefined, $localize`Increase the volume (requires player focus)`),
887 new Hotkey('down', e => e, undefined, $localize`Decrease the volume (requires player focus)`),
889 new Hotkey('right', e => e, undefined, $localize`Seek the video forward (requires player focus)`),
890 new Hotkey('left', e => e, undefined, $localize`Seek the video backward (requires player focus)`),
892 new Hotkey('>', e => e, undefined, $localize`Increase playback rate (requires player focus)`),
893 new Hotkey('<', e => e, undefined, $localize`Decrease playback rate (requires player focus)`),
895 new Hotkey('.', e => e, undefined, $localize`Navigate in the video frame by frame (requires player focus)`)
898 if (this.isUserLoggedIn()) {
899 this.hotkeys = this.hotkeys.concat([
900 new Hotkey('shift+l', () => {
903 }, undefined, $localize`Like the video`),
905 new Hotkey('shift+d', () => {
908 }, undefined, $localize`Dislike the video`),
910 new Hotkey('shift+s', () => {
911 this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
913 }, undefined, $localize`Subscribe to the account`)
917 this.hotkeysService.add(this.hotkeys)