aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos/components/watch/videos-watch.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/videos/components/watch/videos-watch.component.ts')
-rw-r--r--client/angular/videos/components/watch/videos-watch.component.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts
index c35c0ab19..9a8909b75 100644
--- a/client/angular/videos/components/watch/videos-watch.component.ts
+++ b/client/angular/videos/components/watch/videos-watch.component.ts
@@ -1,5 +1,6 @@
1import { Component, OnInit, ElementRef } from 'angular2/core'; 1import { Component, OnInit, ElementRef } from 'angular2/core';
2import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router'; 2import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router';
3import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
3 4
4// TODO import it with systemjs 5// TODO import it with systemjs
5declare var WebTorrent: any; 6declare var WebTorrent: any;
@@ -10,12 +11,17 @@ import { VideosService } from '../../services/videos.service';
10@Component({ 11@Component({
11 selector: 'my-video-watch', 12 selector: 'my-video-watch',
12 templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html', 13 templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html',
13 styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ] 14 styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ],
15 pipes: [ BytesPipe ]
14}) 16})
15 17
16export class VideosWatchComponent implements OnInit, CanDeactivate { 18export class VideosWatchComponent implements OnInit, CanDeactivate {
17 video: Video; 19 video: Video;
20 downloadSpeed: number;
21 uploadSpeed: number;
22 numPeers: number;
18 23
24 private _interval: number;
19 private client: any; 25 private client: any;
20 26
21 constructor( 27 constructor(
@@ -46,11 +52,19 @@ export class VideosWatchComponent implements OnInit, CanDeactivate {
46 console.error(err); 52 console.error(err);
47 } 53 }
48 }); 54 });
55
56 // Refresh each second
57 this._interval = setInterval(() => {
58 this.downloadSpeed = torrent.downloadSpeed;
59 this.uploadSpeed = torrent.uploadSpeed;
60 this.numPeers = torrent.numPeers;
61 }, 1000);
49 }); 62 });
50 } 63 }
51 64
52 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any { 65 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
53 console.log('Removing video from webtorrent.'); 66 console.log('Removing video from webtorrent.');
67 clearInterval(this._interval)
54 this.client.remove(this.video.magnetUri); 68 this.client.remove(this.video.magnetUri);
55 return true; 69 return true;
56 } 70 }