]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Resume video playback on close of support modal (#3052)
authorAman Sharma <amsharma44@users.noreply.github.com>
Mon, 10 Aug 2020 06:32:10 +0000 (12:02 +0530)
committerGitHub <noreply@github.com>
Mon, 10 Aug 2020 06:32:10 +0000 (08:32 +0200)
* Resume video playback on close of support modal #2995

* Fix lint issues

client/src/app/+videos/+video-watch/modal/video-support.component.ts
client/src/app/+videos/+video-watch/video-watch.component.ts

index 48d5f2948640d6a670494697f5a95c9fa810d4dc..bd5290a721666ce36275ab26f1df3eec23661c34 100644 (file)
@@ -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
   }
 }
index d8136ab4ff36dadd56dd8682dffb7a6b00cba271..33f998282628d844d5c0156e0b3f1479953aef58 100644 (file)
@@ -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