aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos/components/watch
diff options
context:
space:
mode:
Diffstat (limited to 'client/angular/videos/components/watch')
-rw-r--r--client/angular/videos/components/watch/videos-watch.component.html10
-rw-r--r--client/angular/videos/components/watch/videos-watch.component.scss13
-rw-r--r--client/angular/videos/components/watch/videos-watch.component.ts78
3 files changed, 0 insertions, 101 deletions
diff --git a/client/angular/videos/components/watch/videos-watch.component.html b/client/angular/videos/components/watch/videos-watch.component.html
deleted file mode 100644
index 6c36b27e2..000000000
--- a/client/angular/videos/components/watch/videos-watch.component.html
+++ /dev/null
@@ -1,10 +0,0 @@
1<my-loader [loading]="loading"></my-loader>
2
3<div class="embed-responsive embed-responsive-19by9">
4</div>
5
6<div id="torrent-info">
7 <div id="torrent-info-download">Download: {{ downloadSpeed | bytes }}/s</div>
8 <div id="torrent-info-upload">Upload: {{ uploadSpeed | bytes }}/s</div>
9 <div id="torrent-info-peers">Number of peers: {{ numPeers }}</div>
10<div>
diff --git a/client/angular/videos/components/watch/videos-watch.component.scss b/client/angular/videos/components/watch/videos-watch.component.scss
deleted file mode 100644
index 1228d42f4..000000000
--- a/client/angular/videos/components/watch/videos-watch.component.scss
+++ /dev/null
@@ -1,13 +0,0 @@
1.embed-responsive {
2 height: 500px;
3}
4
5#torrent-info {
6 font-size: 10px;
7
8 div {
9 display: inline-block;
10 width: 33%;
11 text-align: center;
12 }
13}
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts
deleted file mode 100644
index e551e1f9a..000000000
--- a/client/angular/videos/components/watch/videos-watch.component.ts
+++ /dev/null
@@ -1,78 +0,0 @@
1import { Component, OnInit, ElementRef } from '@angular/core';
2import { RouteParams, CanDeactivate, ComponentInstruction } from '@angular/router-deprecated';
3
4import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
5
6import { LoaderComponent } from '../../loader.component';
7
8// TODO import it with systemjs
9declare var WebTorrent: any;
10
11import { Video } from '../../video';
12import { VideosService } from '../../videos.service';
13
14@Component({
15 selector: 'my-video-watch',
16 templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html',
17 styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ],
18 directives: [ LoaderComponent ],
19 pipes: [ BytesPipe ]
20})
21
22export class VideosWatchComponent implements OnInit, CanDeactivate {
23 video: Video;
24 downloadSpeed: number;
25 uploadSpeed: number;
26 numPeers: number;
27 loading: boolean = false;
28
29 private _interval: NodeJS.Timer;
30 private client: any;
31
32 constructor(
33 private _videosService: VideosService,
34 private _routeParams: RouteParams,
35 private _elementRef: ElementRef
36 ) {
37 // TODO: use a service
38 this.client = new WebTorrent({ dht: false });
39 }
40
41 ngOnInit() {
42 let id = this._routeParams.get('id');
43 this._videosService.getVideo(id).subscribe(
44 video => this.loadVideo(video),
45 error => alert(error)
46 );
47 }
48
49 loadVideo(video: Video) {
50 this.loading = true;
51 this.video = video;
52 console.log('Adding ' + this.video.magnetUri + '.');
53 this.client.add(this.video.magnetUri, (torrent) => {
54 this.loading = false;
55 console.log('Added ' + this.video.magnetUri + '.');
56 torrent.files[0].appendTo(this._elementRef.nativeElement.querySelector('.embed-responsive'), (err) => {
57 if (err) {
58 alert('Cannot append the file.');
59 console.error(err);
60 }
61 });
62
63 // Refresh each second
64 this._interval = setInterval(() => {
65 this.downloadSpeed = torrent.downloadSpeed;
66 this.uploadSpeed = torrent.uploadSpeed;
67 this.numPeers = torrent.numPeers;
68 }, 1000);
69 });
70 }
71
72 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any {
73 console.log('Removing video from webtorrent.');
74 clearInterval(this._interval);
75 this.client.remove(this.video.magnetUri);
76 return true;
77 }
78}