From: Aman Sharma Date: Mon, 10 Aug 2020 06:32:10 +0000 (+0530) Subject: Resume video playback on close of support modal (#3052) X-Git-Tag: v2.4.0-rc.1~140 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=203d594f2d20c6a573e80f7044cce4bce5dd72a9;hp=17384fd85636b9fe672ecb520ba6f2266483d4b1;p=github%2FChocobozzz%2FPeerTube.git Resume video playback on close of support modal (#3052) * Resume video playback on close of support modal #2995 * Fix lint issues --- diff --git a/client/src/app/+videos/+video-watch/modal/video-support.component.ts b/client/src/app/+videos/+video-watch/modal/video-support.component.ts index 48d5f2948..bd5290a72 100644 --- a/client/src/app/+videos/+video-watch/modal/video-support.component.ts +++ b/client/src/app/+videos/+video-watch/modal/video-support.component.ts @@ -21,9 +21,11 @@ export class VideoSupportComponent { ) { } show () { - this.modalService.open(this.modal, { centered: true }) + const modalRef = this.modalService.open(this.modal, { centered: true }) this.markdownService.enhancedMarkdownToHTML(this.video.support) .then(r => this.videoHTMLSupport = r) + + return modalRef } } 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 d8136ab4f..33f998282 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -236,9 +236,18 @@ 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 () { @@ -757,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