aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/videos/video-watch/video-watch.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/app/videos/video-watch/video-watch.component.ts')
-rw-r--r--client/app/videos/video-watch/video-watch.component.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/client/app/videos/video-watch/video-watch.component.ts b/client/app/videos/video-watch/video-watch.component.ts
index 891e6563f..c159b4004 100644
--- a/client/app/videos/video-watch/video-watch.component.ts
+++ b/client/app/videos/video-watch/video-watch.component.ts
@@ -23,21 +23,21 @@ export class VideoWatchComponent implements OnInit, CanDeactivate {
23 numPeers: number; 23 numPeers: number;
24 loading: boolean = false; 24 loading: boolean = false;
25 25
26 private _interval: NodeJS.Timer; 26 private interval: NodeJS.Timer;
27 private client: any; 27 private client: any;
28 28
29 constructor( 29 constructor(
30 private _videoService: VideoService, 30 private videoService: VideoService,
31 private _routeParams: RouteParams, 31 private routeParams: RouteParams,
32 private _elementRef: ElementRef 32 private elementRef: ElementRef
33 ) { 33 ) {
34 // TODO: use a service 34 // TODO: use a service
35 this.client = new WebTorrent({ dht: false }); 35 this.client = new WebTorrent({ dht: false });
36 } 36 }
37 37
38 ngOnInit() { 38 ngOnInit() {
39 let id = this._routeParams.get('id'); 39 let id = this.routeParams.get('id');
40 this._videoService.getVideo(id).subscribe( 40 this.videoService.getVideo(id).subscribe(
41 video => this.loadVideo(video), 41 video => this.loadVideo(video),
42 error => alert(error) 42 error => alert(error)
43 ); 43 );
@@ -50,7 +50,7 @@ export class VideoWatchComponent implements OnInit, CanDeactivate {
50 this.client.add(this.video.magnetUri, (torrent) => { 50 this.client.add(this.video.magnetUri, (torrent) => {
51 this.loading = false; 51 this.loading = false;
52 console.log('Added ' + this.video.magnetUri + '.'); 52 console.log('Added ' + this.video.magnetUri + '.');
53 torrent.files[0].appendTo(this._elementRef.nativeElement.querySelector('.embed-responsive'), (err) => { 53 torrent.files[0].appendTo(this.elementRef.nativeElement.querySelector('.embed-responsive'), (err) => {
54 if (err) { 54 if (err) {
55 alert('Cannot append the file.'); 55 alert('Cannot append the file.');
56 console.error(err); 56 console.error(err);
@@ -58,7 +58,7 @@ export class VideoWatchComponent implements OnInit, CanDeactivate {
58 }); 58 });
59 59
60 // Refresh each second 60 // Refresh each second
61 this._interval = setInterval(() => { 61 this.interval = setInterval(() => {
62 this.downloadSpeed = torrent.downloadSpeed; 62 this.downloadSpeed = torrent.downloadSpeed;
63 this.uploadSpeed = torrent.uploadSpeed; 63 this.uploadSpeed = torrent.uploadSpeed;
64 this.numPeers = torrent.numPeers; 64 this.numPeers = torrent.numPeers;
@@ -66,9 +66,9 @@ export class VideoWatchComponent implements OnInit, CanDeactivate {
66 }); 66 });
67 } 67 }
68 68
69 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any { 69 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) {
70 console.log('Removing video from webtorrent.'); 70 console.log('Removing video from webtorrent.');
71 clearInterval(this._interval); 71 clearInterval(this.interval);
72 this.client.remove(this.video.magnetUri); 72 this.client.remove(this.video.magnetUri);
73 return true; 73 return true;
74 } 74 }