import { Component, OnInit, ElementRef } from 'angular2/core';
import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router';
+import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
// TODO import it with systemjs
declare var WebTorrent: any;
@Component({
selector: 'my-video-watch',
templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html',
- styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ]
+ styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ],
+ pipes: [ BytesPipe ]
})
export class VideosWatchComponent implements OnInit, CanDeactivate {
video: Video;
+ downloadSpeed: number;
+ uploadSpeed: number;
+ numPeers: number;
+ private _interval: number;
private client: any;
constructor(
console.error(err);
}
});
+
+ // Refresh each second
+ this._interval = setInterval(() => {
+ this.downloadSpeed = torrent.downloadSpeed;
+ this.uploadSpeed = torrent.uploadSpeed;
+ this.numPeers = torrent.numPeers;
+ }, 1000);
});
}
routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
console.log('Removing video from webtorrent.');
+ clearInterval(this._interval)
this.client.remove(this.video.magnetUri);
return true;
}
},
"license": "ISC",
"dependencies": {
+ "angular-pipes": "^1.4.1",
"angular2": "2.0.0-beta.14",
"blueimp-file-upload": "^9.12.1",
"bootstrap-sass": "^3.3.6",