From 4fd8aa327004b27530fd96bdde5df60e6745a1f6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 May 2016 17:49:18 +0200 Subject: Alphabetical --- .../videos/video-watch/video-watch.component.ts | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'client/app/videos/video-watch') diff --git a/client/app/videos/video-watch/video-watch.component.ts b/client/app/videos/video-watch/video-watch.component.ts index c159b4004..137db8f0b 100644 --- a/client/app/videos/video-watch/video-watch.component.ts +++ b/client/app/videos/video-watch/video-watch.component.ts @@ -17,32 +17,24 @@ declare var WebTorrent: any; }) export class VideoWatchComponent implements OnInit, CanDeactivate { - video: Video; downloadSpeed: number; - uploadSpeed: number; - numPeers: number; loading: boolean = false; + numPeers: number; + uploadSpeed: number; + video: Video; - private interval: NodeJS.Timer; private client: any; + private interval: NodeJS.Timer; constructor( - private videoService: VideoService, + private elementRef: ElementRef, private routeParams: RouteParams, - private elementRef: ElementRef + private videoService: VideoService ) { // TODO: use a service this.client = new WebTorrent({ dht: false }); } - ngOnInit() { - let id = this.routeParams.get('id'); - this.videoService.getVideo(id).subscribe( - video => this.loadVideo(video), - error => alert(error) - ); - } - loadVideo(video: Video) { this.loading = true; this.video = video; @@ -60,12 +52,20 @@ export class VideoWatchComponent implements OnInit, CanDeactivate { // Refresh each second this.interval = setInterval(() => { this.downloadSpeed = torrent.downloadSpeed; - this.uploadSpeed = torrent.uploadSpeed; this.numPeers = torrent.numPeers; + this.uploadSpeed = torrent.uploadSpeed; }, 1000); }); } + ngOnInit() { + let id = this.routeParams.get('id'); + this.videoService.getVideo(id).subscribe( + video => this.loadVideo(video), + error => alert(error) + ); + } + routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) { console.log('Removing video from webtorrent.'); clearInterval(this.interval); -- cgit v1.2.3