diff options
Diffstat (limited to 'client/src/app/videos/video-watch/video-watch.component.ts')
-rw-r--r-- | client/src/app/videos/video-watch/video-watch.component.ts | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts index 239e24c99..9a36c17e2 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts | |||
@@ -18,7 +18,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
18 | loading: boolean = false; | 18 | loading: boolean = false; |
19 | numPeers: number; | 19 | numPeers: number; |
20 | uploadSpeed: number; | 20 | uploadSpeed: number; |
21 | video: Video; | 21 | video: Video = null; |
22 | 22 | ||
23 | private errorTimer: NodeJS.Timer; | 23 | private errorTimer: NodeJS.Timer; |
24 | private sub: any; | 24 | private sub: any; |
@@ -32,6 +32,28 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
32 | private webTorrentService: WebTorrentService | 32 | private webTorrentService: WebTorrentService |
33 | ) {} | 33 | ) {} |
34 | 34 | ||
35 | ngOnInit() { | ||
36 | this.sub = this.route.params.subscribe(routeParams => { | ||
37 | let id = routeParams['id']; | ||
38 | this.videoService.getVideo(id).subscribe( | ||
39 | video => { | ||
40 | this.video = video; | ||
41 | this.loadVideo(); | ||
42 | }, | ||
43 | error => alert(error.text) | ||
44 | ); | ||
45 | }); | ||
46 | } | ||
47 | |||
48 | ngOnDestroy() { | ||
49 | console.log('Removing video from webtorrent.'); | ||
50 | clearInterval(this.torrentInfosInterval); | ||
51 | clearTimeout(this.errorTimer); | ||
52 | this.webTorrentService.remove(this.video.magnetUri); | ||
53 | |||
54 | this.sub.unsubscribe(); | ||
55 | } | ||
56 | |||
35 | loadVideo() { | 57 | loadVideo() { |
36 | // Reset the error | 58 | // Reset the error |
37 | this.error = false; | 59 | this.error = false; |
@@ -65,28 +87,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
65 | }); | 87 | }); |
66 | } | 88 | } |
67 | 89 | ||
68 | ngOnDestroy() { | ||
69 | console.log('Removing video from webtorrent.'); | ||
70 | clearInterval(this.torrentInfosInterval); | ||
71 | clearTimeout(this.errorTimer); | ||
72 | this.webTorrentService.remove(this.video.magnetUri); | ||
73 | |||
74 | this.sub.unsubscribe(); | ||
75 | } | ||
76 | |||
77 | ngOnInit() { | ||
78 | this.sub = this.route.params.subscribe(routeParams => { | ||
79 | let id = routeParams['id']; | ||
80 | this.videoService.getVideo(id).subscribe( | ||
81 | video => { | ||
82 | this.video = video; | ||
83 | this.loadVideo(); | ||
84 | }, | ||
85 | error => alert(error.text) | ||
86 | ); | ||
87 | }); | ||
88 | } | ||
89 | |||
90 | private loadTooLong() { | 90 | private loadTooLong() { |
91 | this.error = true; | 91 | this.error = true; |
92 | console.error('The video load seems to be abnormally long.'); | 92 | console.error('The video load seems to be abnormally long.'); |