]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-watch/video-watch.component.ts
Resume video playback on close of support modal (#3052)
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / video-watch.component.ts
index dfe73d14d7d0729b19b97cbb762a40dc1b7f01fa..33f998282628d844d5c0156e0b3f1479953aef58 100644 (file)
@@ -236,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 () {
@@ -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