X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-watch%2Fvideo-watch.component.ts;h=33f998282628d844d5c0156e0b3f1479953aef58;hb=10846ef656585ee857ec43fc22b490409ddd0d44;hp=933e6c51fbcd756695e7a22efb8c1b1477f3717e;hpb=7ede74add2d41958f3aad0053afc812698f261a0;p=github%2FChocobozzz%2FPeerTube.git 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 933e6c51f..33f998282 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -7,7 +7,8 @@ import { ActivatedRoute, Router } from '@angular/router' import { AuthService, AuthUser, ConfirmService, MarkdownService, Notifier, RestExtractor, ServerService, UserService } from '@app/core' import { HooksService } from '@app/core/plugins/hooks.service' import { RedirectService } from '@app/core/routing/redirect.service' -import { isXPercentInViewport, peertubeLocalStorage, scrollToTop } from '@app/helpers' +import { isXPercentInViewport, scrollToTop } from '@app/helpers' +import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main' import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' @@ -28,6 +29,7 @@ import { environment } from '../../../environments/environment' import { VideoShareComponent } from './modal/video-share.component' import { VideoSupportComponent } from './modal/video-support.component' import { VideoWatchPlaylistComponent } from './video-watch-playlist.component' +import { VideoDownloadComponent } from '@app/shared/shared-video-miniature' @Component({ selector: 'my-video-watch', @@ -41,6 +43,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { @ViewChild('videoShareModal') videoShareModal: VideoShareComponent @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent + @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent player: any playerElement: HTMLVideoElement @@ -160,6 +163,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { // Unsubscribe subscriptions if (this.paramsSub) this.paramsSub.unsubscribe() if (this.queryParamsSub) this.queryParamsSub.unsubscribe() + if (this.configSub) this.configSub.unsubscribe() // Unbind hotkeys this.hotkeysService.remove(this.hotkeys) @@ -201,6 +205,14 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.completeDescriptionShown = false } + showDownloadModal () { + this.videoDownloadModal.show(this.video, this.videoCaptions) + } + + isVideoDownloadable () { + return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled + } + loadCompleteDescription () { this.descriptionLoading = true @@ -224,15 +236,24 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } showSupportModal () { + // Check video was playing before opening support modal + const isVideoPlaying = this.isPlaying() + this.pausePlayer() - this.videoSupportModal.show() + const modalRef = this.videoSupportModal.show() + + modalRef.result.then(() => { + if (isVideoPlaying) { + this.resumePlayer() + } + }) } showShareModal () { this.pausePlayer() - this.videoShareModal.show(this.currentTime) + this.videoShareModal.show(this.currentTime, this.videoWatchPlaylist.currentPlaylistPosition) } isUserLoggedIn () { @@ -307,6 +328,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy { ) } + isChannelDisplayNameGeneric () { + const genericChannelDisplayName = [ + `Main ${this.video.channel.ownerAccount.name} channel`, + `Default ${this.video.channel.ownerAccount.name} channel` + ] + + return genericChannelDisplayName.includes(this.video.channel.displayName) + } + private loadVideo (videoId: string) { // Video did not change if (this.video && this.video.uuid === videoId) return @@ -736,6 +766,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.player.pause() } + private resumePlayer () { + if (!this.player) return + + this.player.play() + } + + private isPlaying () { + if (!this.player) return + + return !this.player.paused() + } + private initHotkeys () { this.hotkeys = [ // These hotkeys are managed by the player