]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/modal/video-download.component.ts
Add context menu to player
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / modal / video-download.component.ts
index 3b409e2e6656c700f6eeab5024e3f1b514e21070..12f31b011a093fbbd6e0916b1b3eb12263edfb9c 100644 (file)
@@ -13,14 +13,14 @@ export class VideoDownloadComponent implements OnInit {
   @ViewChild('modal') modal: ModalDirective
 
   downloadType: 'direct' | 'torrent' = 'torrent'
-  resolution: number | string = -1
+  resolutionId: number | string = -1
 
   constructor () {
     // empty
   }
 
   ngOnInit () {
-    this.resolution = this.video.files[0].resolution
+    this.resolutionId = this.video.files[0].resolution.id
   }
 
   show () {
@@ -33,15 +33,15 @@ export class VideoDownloadComponent implements OnInit {
 
   download () {
     // HTML select send us a string, so convert it to a number
-    this.resolution = parseInt(this.resolution.toString(), 10)
+    this.resolutionId = parseInt(this.resolutionId.toString(), 10)
 
-    const file = this.video.files.find(f => f.resolution === this.resolution)
+    const file = this.video.files.find(f => f.resolution.id === this.resolutionId)
     if (!file) {
-      console.error('Could not find file with resolution %d.', this.resolution)
+      console.error('Could not find file with resolution %d.', this.resolutionId)
       return
     }
 
-    const link = this.downloadType === 'direct' ? file.fileUrl : file.torrentUrl
-    window.open(link)
+    const link = this.downloadType === 'direct' ? file.fileDownloadUrl : file.torrentDownloadUrl
+    window.location.assign(link)
   }
 }