aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/video-watch
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/video-watch')
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts12
1 files changed, 10 insertions, 2 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 0ae323c9f..0309938c0 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -25,6 +25,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
25 loading: boolean = false; 25 loading: boolean = false;
26 numPeers: number; 26 numPeers: number;
27 player: VideoJSPlayer; 27 player: VideoJSPlayer;
28 playerElement: Element;
28 uploadSpeed: number; 29 uploadSpeed: number;
29 video: Video = null; 30 video: Video = null;
30 31
@@ -54,23 +55,30 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
54 ); 55 );
55 }); 56 });
56 57
58 this.playerElement = this.elementRef.nativeElement.querySelector('#video-container');
59
57 const videojsOptions = { 60 const videojsOptions = {
58 controls: true, 61 controls: true,
59 autoplay: false 62 autoplay: false
60 }; 63 };
61 64
62 const self = this; 65 const self = this;
63 videojs('video-container', videojsOptions, function () { 66 videojs(this.playerElement, videojsOptions, function () {
64 self.player = this; 67 self.player = this;
65 }); 68 });
66 } 69 }
67 70
68 ngOnDestroy() { 71 ngOnDestroy() {
72 // Remove WebTorrent stuff
69 console.log('Removing video from webtorrent.'); 73 console.log('Removing video from webtorrent.');
70 clearInterval(this.torrentInfosInterval); 74 clearInterval(this.torrentInfosInterval);
71 clearTimeout(this.errorTimer); 75 clearTimeout(this.errorTimer);
72 this.webTorrentService.remove(this.video.magnetUri); 76 this.webTorrentService.remove(this.video.magnetUri);
73 77
78 // Remove player
79 videojs(this.playerElement).dispose();
80
81 // Unsubscribe route subscription
74 this.sub.unsubscribe(); 82 this.sub.unsubscribe();
75 } 83 }
76 84
@@ -96,7 +104,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
96 this.loading = false; 104 this.loading = false;
97 105
98 console.log('Added ' + this.video.magnetUri + '.'); 106 console.log('Added ' + this.video.magnetUri + '.');
99 torrent.files[0].renderTo('#video-container video', { autoplay: true }, (err) => { 107 torrent.files[0].renderTo(this.playerElement, { autoplay: true }, (err) => {
100 if (err) { 108 if (err) {
101 alert('Cannot append the file.'); 109 alert('Cannot append the file.');
102 console.error(err); 110 console.error(err);