]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+videos/+video-watch/video-watch.component.ts
85b8822257bf3714b53ec58be33ef3632f756be3
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / video-watch.component.ts
1 import { Hotkey, HotkeysService } from 'angular2-hotkeys'
2 import { forkJoin, Subscription } from 'rxjs'
3 import { PlatformLocation } from '@angular/common'
4 import { Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
5 import { ActivatedRoute, Router } from '@angular/router'
6 import {
7 AuthService,
8 AuthUser,
9 ConfirmService,
10 MetaService,
11 Notifier,
12 PeerTubeSocket,
13 PluginService,
14 RestExtractor,
15 ScreenService,
16 ServerService,
17 UserService
18 } from '@app/core'
19 import { HooksService } from '@app/core/plugins/hooks.service'
20 import { isXPercentInViewport, scrollToTop } from '@app/helpers'
21 import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
22 import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
23 import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
24 import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
25 import { HTMLServerConfig, PeerTubeProblemDocument, ServerErrorCode, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
26 import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage'
27 import {
28 CustomizationOptions,
29 P2PMediaLoaderOptions,
30 PeertubePlayerManager,
31 PeertubePlayerManagerOptions,
32 PlayerMode,
33 videojs
34 } from '../../../assets/player/peertube-player-manager'
35 import { timeToInt } from '../../../assets/player/utils'
36 import { environment } from '../../../environments/environment'
37 import { VideoWatchPlaylistComponent } from './shared'
38
39 type URLOptions = CustomizationOptions & { playerMode: PlayerMode }
40
41 @Component({
42 selector: 'my-video-watch',
43 templateUrl: './video-watch.component.html',
44 styleUrls: [ './video-watch.component.scss' ]
45 })
46 export class VideoWatchComponent implements OnInit, OnDestroy {
47 @ViewChild('videoWatchPlaylist', { static: true }) videoWatchPlaylist: VideoWatchPlaylistComponent
48 @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
49
50 player: any
51 playerElement: HTMLVideoElement
52 playerPlaceholderImgSrc: string
53 theaterEnabled = false
54
55 video: VideoDetails = null
56 videoCaptions: VideoCaption[] = []
57
58 playlistPosition: number
59 playlist: VideoPlaylist = null
60
61 remoteServerDown = false
62
63 private nextVideoUUID = ''
64 private nextVideoTitle = ''
65
66 private currentTime: number
67
68 private paramsSub: Subscription
69 private queryParamsSub: Subscription
70 private configSub: Subscription
71 private liveVideosSub: Subscription
72
73 private serverConfig: HTMLServerConfig
74
75 private hotkeys: Hotkey[] = []
76
77 constructor (
78 private elementRef: ElementRef,
79 private route: ActivatedRoute,
80 private router: Router,
81 private videoService: VideoService,
82 private playlistService: VideoPlaylistService,
83 private confirmService: ConfirmService,
84 private metaService: MetaService,
85 private authService: AuthService,
86 private userService: UserService,
87 private serverService: ServerService,
88 private restExtractor: RestExtractor,
89 private notifier: Notifier,
90 private zone: NgZone,
91 private videoCaptionService: VideoCaptionService,
92 private hotkeysService: HotkeysService,
93 private hooks: HooksService,
94 private pluginService: PluginService,
95 private peertubeSocket: PeerTubeSocket,
96 private screenService: ScreenService,
97 private location: PlatformLocation,
98 @Inject(LOCALE_ID) private localeId: string
99 ) { }
100
101 get user () {
102 return this.authService.getUser()
103 }
104
105 get anonymousUser () {
106 return this.userService.getAnonymousUser()
107 }
108
109 async ngOnInit () {
110 this.serverConfig = this.serverService.getHTMLConfig()
111
112 PeertubePlayerManager.initState()
113
114 this.loadRouteParams()
115 this.loadRouteQuery()
116
117 this.initHotkeys()
118
119 this.theaterEnabled = getStoredTheater()
120
121 this.hooks.runAction('action:video-watch.init', 'video-watch')
122
123 setTimeout(cleanupVideoWatch, 1500) // Run in timeout to ensure we're not blocking the UI
124 }
125
126 ngOnDestroy () {
127 this.flushPlayer()
128
129 // Unsubscribe subscriptions
130 if (this.paramsSub) this.paramsSub.unsubscribe()
131 if (this.queryParamsSub) this.queryParamsSub.unsubscribe()
132 if (this.configSub) this.configSub.unsubscribe()
133 if (this.liveVideosSub) this.liveVideosSub.unsubscribe()
134
135 // Unbind hotkeys
136 this.hotkeysService.remove(this.hotkeys)
137 }
138
139 getCurrentTime () {
140 return this.currentTime
141 }
142
143 getCurrentPlaylistPosition () {
144 return this.videoWatchPlaylist.currentPlaylistPosition
145 }
146
147 onRecommendations (videos: Video[]) {
148 if (videos.length === 0) return
149
150 // The recommended videos's first element should be the next video
151 const video = videos[0]
152 this.nextVideoUUID = video.uuid
153 this.nextVideoTitle = video.name
154 }
155
156 handleTimestampClicked (timestamp: number) {
157 if (!this.player || this.video.isLive) return
158
159 this.player.currentTime(timestamp)
160 scrollToTop()
161 }
162
163 onPlaylistVideoFound (videoId: string) {
164 this.loadVideo(videoId)
165 }
166
167 isUserLoggedIn () {
168 return this.authService.isLoggedIn()
169 }
170
171 isVideoBlur (video: Video) {
172 return video.isVideoNSFWForUser(this.user, this.serverConfig)
173 }
174
175 isChannelDisplayNameGeneric () {
176 const genericChannelDisplayName = [
177 `Main ${this.video.channel.ownerAccount.name} channel`,
178 `Default ${this.video.channel.ownerAccount.name} channel`
179 ]
180
181 return genericChannelDisplayName.includes(this.video.channel.displayName)
182 }
183
184 displayOtherVideosAsRow () {
185 // Use the same value as in the SASS file
186 return this.screenService.getWindowInnerWidth() <= 1100
187 }
188
189 private loadRouteParams () {
190 this.paramsSub = this.route.params.subscribe(routeParams => {
191 const videoId = routeParams[ 'videoId' ]
192 if (videoId) return this.loadVideo(videoId)
193
194 const playlistId = routeParams[ 'playlistId' ]
195 if (playlistId) return this.loadPlaylist(playlistId)
196 })
197 }
198
199 private loadRouteQuery () {
200 this.queryParamsSub = this.route.queryParams.subscribe(queryParams => {
201 // Handle the ?playlistPosition
202 const positionParam = queryParams[ 'playlistPosition' ] ?? 1
203
204 this.playlistPosition = positionParam === 'last'
205 ? -1 // Handle the "last" index
206 : parseInt(positionParam + '', 10)
207
208 if (isNaN(this.playlistPosition)) {
209 console.error(`playlistPosition query param '${positionParam}' was parsed as NaN, defaulting to 1.`)
210 this.playlistPosition = 1
211 }
212
213 this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition)
214
215 const start = queryParams[ 'start' ]
216 if (this.player && start) this.player.currentTime(parseInt(start, 10))
217 })
218 }
219
220 private loadVideo (videoId: string) {
221 if (this.isSameElement(this.video, videoId)) return
222
223 if (this.player) this.player.pause()
224
225 const videoObs = this.hooks.wrapObsFun(
226 this.videoService.getVideo.bind(this.videoService),
227 { videoId },
228 'video-watch',
229 'filter:api.video-watch.video.get.params',
230 'filter:api.video-watch.video.get.result'
231 )
232
233 forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId)])
234 .subscribe(
235 ([ video, captionsResult ]) => {
236 const queryParams = this.route.snapshot.queryParams
237
238 const urlOptions = {
239 resume: queryParams.resume,
240
241 startTime: queryParams.start,
242 stopTime: queryParams.stop,
243
244 muted: queryParams.muted,
245 loop: queryParams.loop,
246 subtitle: queryParams.subtitle,
247
248 playerMode: queryParams.mode,
249 peertubeLink: false
250 }
251
252 this.onVideoFetched(video, captionsResult.data, urlOptions)
253 .catch(err => this.handleGlobalError(err))
254 },
255
256 err => this.handleRequestError(err)
257 )
258 }
259
260 private loadPlaylist (playlistId: string) {
261 if (this.isSameElement(this.playlist, playlistId)) return
262
263 this.playlistService.getVideoPlaylist(playlistId)
264 .subscribe(
265 playlist => {
266 this.playlist = playlist
267
268 this.videoWatchPlaylist.loadPlaylistElements(playlist, !this.playlistPosition, this.playlistPosition)
269 },
270
271 err => this.handleRequestError(err)
272 )
273 }
274
275 private isSameElement (element: VideoDetails | VideoPlaylist, newId: string) {
276 if (!element) return false
277
278 return (element.id + '') === newId || element.uuid === newId || element.shortUUID === newId
279 }
280
281 private async handleRequestError (err: any) {
282 const errorBody = err.body as PeerTubeProblemDocument
283
284 if (errorBody.code === ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS && errorBody.originUrl) {
285 const originUrl = errorBody.originUrl + (window.location.search ?? '')
286
287 const res = await this.confirmService.confirm(
288 $localize`This video is not available on this instance. Do you want to be redirected on the origin instance: <a href="${originUrl}">${originUrl}</a>?`,
289 $localize`Redirection`
290 )
291
292 if (res === true) return window.location.href = originUrl
293 }
294
295 // If 400, 403 or 404, the video is private or blocked so redirect to 404
296 return this.restExtractor.redirectTo404IfNotFound(err, 'video', [
297 HttpStatusCode.BAD_REQUEST_400,
298 HttpStatusCode.FORBIDDEN_403,
299 HttpStatusCode.NOT_FOUND_404
300 ])
301 }
302
303 private handleGlobalError (err: any) {
304 const errorMessage: string = typeof err === 'string' ? err : err.message
305 if (!errorMessage) return
306
307 // Display a message in the video player instead of a notification
308 if (errorMessage.indexOf('from xs param') !== -1) {
309 this.flushPlayer()
310 this.remoteServerDown = true
311
312 return
313 }
314
315 this.notifier.error(errorMessage)
316 }
317
318 private async onVideoFetched (
319 video: VideoDetails,
320 videoCaptions: VideoCaption[],
321 urlOptions: URLOptions
322 ) {
323 this.subscribeToLiveEventsIfNeeded(this.video, video)
324
325 this.video = video
326 this.videoCaptions = videoCaptions
327
328 // Re init attributes
329 this.playerPlaceholderImgSrc = undefined
330 this.remoteServerDown = false
331 this.currentTime = undefined
332
333 if (this.isVideoBlur(this.video)) {
334 const res = await this.confirmService.confirm(
335 $localize`This video contains mature or explicit content. Are you sure you want to watch it?`,
336 $localize`Mature or explicit content`
337 )
338 if (res === false) return this.location.back()
339 }
340
341 this.buildPlayer(urlOptions)
342 .catch(err => console.error('Cannot build the player', err))
343
344 this.setOpenGraphTags()
345
346 const hookOptions = {
347 videojs,
348 video: this.video,
349 playlist: this.playlist
350 }
351 this.hooks.runAction('action:video-watch.video.loaded', 'video-watch', hookOptions)
352 }
353
354 private async buildPlayer (urlOptions: URLOptions) {
355 // Flush old player if needed
356 this.flushPlayer()
357
358 const videoState = this.video.state.id
359 if (videoState === VideoState.LIVE_ENDED || videoState === VideoState.WAITING_FOR_LIVE) {
360 this.playerPlaceholderImgSrc = this.video.previewPath
361 return
362 }
363
364 // Build video element, because videojs removes it on dispose
365 const playerElementWrapper = this.elementRef.nativeElement.querySelector('#videojs-wrapper')
366 this.playerElement = document.createElement('video')
367 this.playerElement.className = 'video-js vjs-peertube-skin'
368 this.playerElement.setAttribute('playsinline', 'true')
369 playerElementWrapper.appendChild(this.playerElement)
370
371 const params = {
372 video: this.video,
373 videoCaptions: this.videoCaptions,
374 urlOptions,
375 user: this.user
376 }
377 const { playerMode, playerOptions } = await this.hooks.wrapFun(
378 this.buildPlayerManagerOptions.bind(this),
379 params,
380 'video-watch',
381 'filter:internal.video-watch.player.build-options.params',
382 'filter:internal.video-watch.player.build-options.result'
383 )
384
385 this.zone.runOutsideAngular(async () => {
386 this.player = await PeertubePlayerManager.initialize(playerMode, playerOptions, player => this.player = player)
387
388 this.player.on('customError', ({ err }: { err: any }) => {
389 this.zone.run(() => this.handleGlobalError(err))
390 })
391
392 this.player.on('timeupdate', () => {
393 // Don't need to trigger angular change for this variable, that is sent to children components on click
394 this.currentTime = Math.floor(this.player.currentTime())
395 })
396
397 /**
398 * condition: true to make the upnext functionality trigger, false to disable the upnext functionality
399 * go to the next video in 'condition()' if you don't want of the timer.
400 * next: function triggered at the end of the timer.
401 * suspended: function used at each click of the timer checking if we need to reset progress
402 * and wait until suspended becomes truthy again.
403 */
404 this.player.upnext({
405 timeout: 5000, // 5s
406
407 headText: $localize`Up Next`,
408 cancelText: $localize`Cancel`,
409 suspendedText: $localize`Autoplay is suspended`,
410
411 getTitle: () => this.nextVideoTitle,
412
413 next: () => this.zone.run(() => this.playNextVideoInAngularZone()),
414 condition: () => {
415 if (!this.playlist) return this.isAutoPlayNext()
416
417 // Don't wait timeout to play the next playlist video
418 if (this.isPlaylistAutoPlayNext()) {
419 this.playNextVideoInAngularZone()
420 return undefined
421 }
422
423 return false
424 },
425
426 suspended: () => {
427 return (
428 !isXPercentInViewport(this.player.el(), 80) ||
429 !document.getElementById('content').contains(document.activeElement)
430 )
431 }
432 })
433
434 this.player.one('stopped', () => {
435 if (this.playlist && this.isPlaylistAutoPlayNext()) {
436 this.playNextVideoInAngularZone()
437 }
438 })
439
440 this.player.one('ended', () => {
441 if (this.video.isLive) {
442 this.zone.run(() => this.video.state.id = VideoState.LIVE_ENDED)
443 }
444 })
445
446 this.player.on('theaterChange', (_: any, enabled: boolean) => {
447 this.zone.run(() => this.theaterEnabled = enabled)
448 })
449
450 this.hooks.runAction('action:video-watch.player.loaded', 'video-watch', { player: this.player, videojs, video: this.video })
451 })
452 }
453
454 private playNextVideoInAngularZone () {
455 if (this.playlist) {
456 this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
457 return
458 }
459
460 if (this.nextVideoUUID) {
461 this.router.navigate([ '/w', this.nextVideoUUID ])
462 return
463 }
464 }
465
466 private isAutoplay () {
467 // We'll jump to the thread id, so do not play the video
468 if (this.route.snapshot.params['threadId']) return false
469
470 // Otherwise true by default
471 if (!this.user) return true
472
473 // Be sure the autoPlay is set to false
474 return this.user.autoPlayVideo !== false
475 }
476
477 private isAutoPlayNext () {
478 return (
479 (this.user && this.user.autoPlayNextVideo) ||
480 this.anonymousUser.autoPlayNextVideo
481 )
482 }
483
484 private isPlaylistAutoPlayNext () {
485 return (
486 (this.user && this.user.autoPlayNextVideoPlaylist) ||
487 this.anonymousUser.autoPlayNextVideoPlaylist
488 )
489 }
490
491 private flushPlayer () {
492 // Remove player if it exists
493 if (!this.player) return
494
495 try {
496 this.player.dispose()
497 this.player = undefined
498 } catch (err) {
499 console.error('Cannot dispose player.', err)
500 }
501 }
502
503 private buildPlayerManagerOptions (params: {
504 video: VideoDetails,
505 videoCaptions: VideoCaption[],
506 urlOptions: CustomizationOptions & { playerMode: PlayerMode },
507 user?: AuthUser
508 }) {
509 const { video, videoCaptions, urlOptions, user } = params
510
511 const getStartTime = () => {
512 const byUrl = urlOptions.startTime !== undefined
513 const byHistory = video.userHistory && (!this.playlist || urlOptions.resume !== undefined)
514 const byLocalStorage = getStoredVideoWatchHistory(video.uuid)
515
516 if (byUrl) return timeToInt(urlOptions.startTime)
517 if (byHistory) return video.userHistory.currentTime
518 if (byLocalStorage) return byLocalStorage.duration
519
520 return 0
521 }
522
523 let startTime = getStartTime()
524
525 // If we are at the end of the video, reset the timer
526 if (video.duration - startTime <= 1) startTime = 0
527
528 const playerCaptions = videoCaptions.map(c => ({
529 label: c.language.label,
530 language: c.language.id,
531 src: environment.apiUrl + c.captionPath
532 }))
533
534 const options: PeertubePlayerManagerOptions = {
535 common: {
536 autoplay: this.isAutoplay(),
537 nextVideo: () => this.playNextVideoInAngularZone(),
538
539 playerElement: this.playerElement,
540 onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,
541
542 videoDuration: video.duration,
543 enableHotkeys: true,
544 inactivityTimeout: 2500,
545 poster: video.previewUrl,
546
547 startTime,
548 stopTime: urlOptions.stopTime,
549 controls: urlOptions.controls,
550 muted: urlOptions.muted,
551 loop: urlOptions.loop,
552 subtitle: urlOptions.subtitle,
553
554 peertubeLink: urlOptions.peertubeLink,
555
556 theaterButton: true,
557 captions: videoCaptions.length !== 0,
558
559 videoViewUrl: video.privacy.id !== VideoPrivacy.PRIVATE
560 ? this.videoService.getVideoViewUrl(video.uuid)
561 : null,
562 embedUrl: video.embedUrl,
563 embedTitle: video.name,
564
565 isLive: video.isLive,
566
567 language: this.localeId,
568
569 userWatching: user && user.videosHistoryEnabled === true ? {
570 url: this.videoService.getUserWatchingVideoUrl(video.uuid),
571 authorizationHeader: this.authService.getRequestHeaderValue()
572 } : undefined,
573
574 serverUrl: environment.apiUrl,
575
576 videoCaptions: playerCaptions,
577
578 videoUUID: video.uuid
579 },
580
581 webtorrent: {
582 videoFiles: video.files
583 },
584
585 pluginsManager: this.pluginService.getPluginsManager()
586 }
587
588 // Only set this if we're in a playlist
589 if (this.playlist) {
590 options.common.previousVideo = () => {
591 this.zone.run(() => this.videoWatchPlaylist.navigateToPreviousPlaylistVideo())
592 }
593 }
594
595 let mode: PlayerMode
596
597 if (urlOptions.playerMode) {
598 if (urlOptions.playerMode === 'p2p-media-loader') mode = 'p2p-media-loader'
599 else mode = 'webtorrent'
600 } else {
601 if (video.hasHlsPlaylist()) mode = 'p2p-media-loader'
602 else mode = 'webtorrent'
603 }
604
605 // p2p-media-loader needs TextEncoder, fallback on WebTorrent if not available
606 if (typeof TextEncoder === 'undefined') {
607 mode = 'webtorrent'
608 }
609
610 if (mode === 'p2p-media-loader') {
611 const hlsPlaylist = video.getHlsPlaylist()
612
613 const p2pMediaLoader = {
614 playlistUrl: hlsPlaylist.playlistUrl,
615 segmentsSha256Url: hlsPlaylist.segmentsSha256Url,
616 redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl),
617 trackerAnnounce: video.trackerUrls,
618 videoFiles: hlsPlaylist.files
619 } as P2PMediaLoaderOptions
620
621 Object.assign(options, { p2pMediaLoader })
622 }
623
624 return { playerMode: mode, playerOptions: options }
625 }
626
627 private async subscribeToLiveEventsIfNeeded (oldVideo: VideoDetails, newVideo: VideoDetails) {
628 if (!this.liveVideosSub) {
629 this.liveVideosSub = this.buildLiveEventsSubscription()
630 }
631
632 if (oldVideo && oldVideo.id !== newVideo.id) {
633 await this.peertubeSocket.unsubscribeLiveVideos(oldVideo.id)
634 }
635
636 if (!newVideo.isLive) return
637
638 await this.peertubeSocket.subscribeToLiveVideosSocket(newVideo.id)
639 }
640
641 private buildLiveEventsSubscription () {
642 return this.peertubeSocket.getLiveVideosObservable()
643 .subscribe(({ type, payload }) => {
644 if (type === 'state-change') return this.handleLiveStateChange(payload.state)
645 if (type === 'views-change') return this.handleLiveViewsChange(payload.views)
646 })
647 }
648
649 private handleLiveStateChange (newState: VideoState) {
650 if (newState !== VideoState.PUBLISHED) return
651
652 const videoState = this.video.state.id
653 if (videoState !== VideoState.WAITING_FOR_LIVE && videoState !== VideoState.LIVE_ENDED) return
654
655 console.log('Loading video after live update.')
656
657 const videoUUID = this.video.uuid
658
659 // Reset to force refresh the video
660 this.video = undefined
661 this.loadVideo(videoUUID)
662 }
663
664 private handleLiveViewsChange (newViews: number) {
665 if (!this.video) {
666 console.error('Cannot update video live views because video is no defined.')
667 return
668 }
669
670 console.log('Updating live views.')
671
672 this.video.views = newViews
673 }
674
675 private initHotkeys () {
676 this.hotkeys = [
677 // These hotkeys are managed by the player
678 new Hotkey('f', e => e, undefined, $localize`Enter/exit fullscreen (requires player focus)`),
679 new Hotkey('space', e => e, undefined, $localize`Play/Pause the video (requires player focus)`),
680 new Hotkey('m', e => e, undefined, $localize`Mute/unmute the video (requires player focus)`),
681
682 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)`),
683
684 new Hotkey('up', e => e, undefined, $localize`Increase the volume (requires player focus)`),
685 new Hotkey('down', e => e, undefined, $localize`Decrease the volume (requires player focus)`),
686
687 new Hotkey('right', e => e, undefined, $localize`Seek the video forward (requires player focus)`),
688 new Hotkey('left', e => e, undefined, $localize`Seek the video backward (requires player focus)`),
689
690 new Hotkey('>', e => e, undefined, $localize`Increase playback rate (requires player focus)`),
691 new Hotkey('<', e => e, undefined, $localize`Decrease playback rate (requires player focus)`),
692
693 new Hotkey('.', e => e, undefined, $localize`Navigate in the video frame by frame (requires player focus)`)
694 ]
695
696 if (this.isUserLoggedIn()) {
697 this.hotkeys = this.hotkeys.concat([
698 new Hotkey('shift+s', () => {
699 this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
700 return false
701 }, undefined, $localize`Subscribe to the account`)
702 ])
703 }
704
705 this.hotkeysService.add(this.hotkeys)
706 }
707
708 private setOpenGraphTags () {
709 this.metaService.setTitle(this.video.name)
710
711 this.metaService.setTag('og:type', 'video')
712
713 this.metaService.setTag('og:title', this.video.name)
714 this.metaService.setTag('name', this.video.name)
715
716 this.metaService.setTag('og:description', this.video.description)
717 this.metaService.setTag('description', this.video.description)
718
719 this.metaService.setTag('og:image', this.video.previewPath)
720
721 this.metaService.setTag('og:duration', this.video.duration.toString())
722
723 this.metaService.setTag('og:site_name', 'PeerTube')
724
725 this.metaService.setTag('og:url', window.location.href)
726 this.metaService.setTag('url', window.location.href)
727 }
728 }