aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/videos/video-watch
diff options
context:
space:
mode:
Diffstat (limited to 'client/app/videos/video-watch')
-rw-r--r--client/app/videos/video-watch/video-watch.component.ts30
1 files changed, 15 insertions, 15 deletions
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;
17}) 17})
18 18
19export class VideoWatchComponent implements OnInit, CanDeactivate { 19export class VideoWatchComponent implements OnInit, CanDeactivate {
20 video: Video;
21 downloadSpeed: number; 20 downloadSpeed: number;
22 uploadSpeed: number;
23 numPeers: number;
24 loading: boolean = false; 21 loading: boolean = false;
22 numPeers: number;
23 uploadSpeed: number;
24 video: Video;
25 25
26 private interval: NodeJS.Timer;
27 private client: any; 26 private client: any;
27 private interval: NodeJS.Timer;
28 28
29 constructor( 29 constructor(
30 private videoService: VideoService, 30 private elementRef: ElementRef,
31 private routeParams: RouteParams, 31 private routeParams: RouteParams,
32 private elementRef: ElementRef 32 private videoService: VideoService
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() {
39 let id = this.routeParams.get('id');
40 this.videoService.getVideo(id).subscribe(
41 video => this.loadVideo(video),
42 error => alert(error)
43 );
44 }
45
46 loadVideo(video: Video) { 38 loadVideo(video: Video) {
47 this.loading = true; 39 this.loading = true;
48 this.video = video; 40 this.video = video;
@@ -60,12 +52,20 @@ export class VideoWatchComponent implements OnInit, CanDeactivate {
60 // Refresh each second 52 // Refresh each second
61 this.interval = setInterval(() => { 53 this.interval = setInterval(() => {
62 this.downloadSpeed = torrent.downloadSpeed; 54 this.downloadSpeed = torrent.downloadSpeed;
63 this.uploadSpeed = torrent.uploadSpeed;
64 this.numPeers = torrent.numPeers; 55 this.numPeers = torrent.numPeers;
56 this.uploadSpeed = torrent.uploadSpeed;
65 }, 1000); 57 }, 1000);
66 }); 58 });
67 } 59 }
68 60
61 ngOnInit() {
62 let id = this.routeParams.get('id');
63 this.videoService.getVideo(id).subscribe(
64 video => this.loadVideo(video),
65 error => alert(error)
66 );
67 }
68
69 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) { 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);