blob: 1a73ea6df0de8796e62ad23f4935db614c1bee1c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { ModalDirective } from 'ngx-bootstrap/modal'
import { VideoDetails } from '../../../shared/video/video-details.model'
@Component({
selector: 'my-video-download',
templateUrl: './video-download.component.html',
styleUrls: [ './video-download.component.scss' ]
})
export class VideoDownloadComponent implements OnInit {
@Input() video: VideoDetails = null
@ViewChild('modal') modal: ModalDirective
downloadType: 'direct' | 'torrent' = 'torrent'
resolution = -1
constructor () {
// empty
}
ngOnInit () {
this.resolution = this.video.files[0].resolution
}
show () {
this.modal.show()
}
hide () {
this.modal.hide()
}
download () {
const file = this.video.files.find(f => f.resolution === this.resolution)
if (!file) {
console.error('Could not find file with resolution %d.', this.resolution)
return
}
const link = this.downloadType === 'direct' ? file.fileUrl : file.torrentUrl
window.open(link)
}
}
|