aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/videos/video-watch
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-03 22:08:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-03 22:08:03 +0200
commit4a6995be18b15de1834a39c8921a0e4109671bb6 (patch)
treeb659661cea33687fcc6bd8fc2251cb7a15ab9f9d /client/app/videos/video-watch
parent468892541175f9662f8b1b977e819dc1a496f282 (diff)
downloadPeerTube-4a6995be18b15de1834a39c8921a0e4109671bb6.tar.gz
PeerTube-4a6995be18b15de1834a39c8921a0e4109671bb6.tar.zst
PeerTube-4a6995be18b15de1834a39c8921a0e4109671bb6.zip
First draft to use webpack instead of systemjs
Diffstat (limited to 'client/app/videos/video-watch')
-rw-r--r--client/app/videos/video-watch/index.ts2
-rw-r--r--client/app/videos/video-watch/video-watch.component.html10
-rw-r--r--client/app/videos/video-watch/video-watch.component.scss13
-rw-r--r--client/app/videos/video-watch/video-watch.component.ts72
-rw-r--r--client/app/videos/video-watch/webtorrent.service.ts26
5 files changed, 0 insertions, 123 deletions
diff --git a/client/app/videos/video-watch/index.ts b/client/app/videos/video-watch/index.ts
deleted file mode 100644
index b17aaacf2..000000000
--- a/client/app/videos/video-watch/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
1export * from './video-watch.component';
2export * from './webtorrent.service';
diff --git a/client/app/videos/video-watch/video-watch.component.html b/client/app/videos/video-watch/video-watch.component.html
deleted file mode 100644
index 6c36b27e2..000000000
--- a/client/app/videos/video-watch/video-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/app/videos/video-watch/video-watch.component.scss b/client/app/videos/video-watch/video-watch.component.scss
deleted file mode 100644
index 1228d42f4..000000000
--- a/client/app/videos/video-watch/video-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/app/videos/video-watch/video-watch.component.ts b/client/app/videos/video-watch/video-watch.component.ts
deleted file mode 100644
index 71fb4f634..000000000
--- a/client/app/videos/video-watch/video-watch.component.ts
+++ /dev/null
@@ -1,72 +0,0 @@
1import { Component, ElementRef, OnInit } from '@angular/core';
2import { CanDeactivate, ComponentInstruction, RouteParams } from '@angular/router-deprecated';
3
4import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
5
6import { LoaderComponent, Video, VideoService } from '../shared/index';
7import { WebTorrentService } from './webtorrent.service';
8
9@Component({
10 selector: 'my-video-watch',
11 templateUrl: 'client/app/videos/video-watch/video-watch.component.html',
12 styleUrls: [ 'client/app/videos/video-watch/video-watch.component.css' ],
13 providers: [ WebTorrentService ],
14 directives: [ LoaderComponent ],
15 pipes: [ BytesPipe ]
16})
17
18export class VideoWatchComponent implements OnInit, CanDeactivate {
19 downloadSpeed: number;
20 loading: boolean = false;
21 numPeers: number;
22 uploadSpeed: number;
23 video: Video;
24
25 private interval: NodeJS.Timer;
26
27 constructor(
28 private elementRef: ElementRef,
29 private routeParams: RouteParams,
30 private videoService: VideoService,
31 private webTorrentService: WebTorrentService
32 ) {}
33
34 loadVideo(video: Video) {
35 this.loading = true;
36 this.video = video;
37 console.log('Adding ' + this.video.magnetUri + '.');
38
39 this.webTorrentService.add(this.video.magnetUri, (torrent) => {
40 this.loading = false;
41 console.log('Added ' + this.video.magnetUri + '.');
42 torrent.files[0].appendTo(this.elementRef.nativeElement.querySelector('.embed-responsive'), (err) => {
43 if (err) {
44 alert('Cannot append the file.');
45 console.error(err);
46 }
47 });
48
49 // Refresh each second
50 this.interval = setInterval(() => {
51 this.downloadSpeed = torrent.downloadSpeed;
52 this.numPeers = torrent.numPeers;
53 this.uploadSpeed = torrent.uploadSpeed;
54 }, 1000);
55 });
56 }
57
58 ngOnInit() {
59 let id = this.routeParams.get('id');
60 this.videoService.getVideo(id).subscribe(
61 video => this.loadVideo(video),
62 error => alert(error)
63 );
64 }
65
66 routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) {
67 console.log('Removing video from webtorrent.');
68 clearInterval(this.interval);
69 this.webTorrentService.remove(this.video.magnetUri);
70 return true;
71 }
72}
diff --git a/client/app/videos/video-watch/webtorrent.service.ts b/client/app/videos/video-watch/webtorrent.service.ts
deleted file mode 100644
index 0c73ab4f4..000000000
--- a/client/app/videos/video-watch/webtorrent.service.ts
+++ /dev/null
@@ -1,26 +0,0 @@
1// Don't use webtorrent typings for now
2// It misses some little things I'll fix later
3// <reference path="../../../typings/globals/webtorrent/index.d.ts" />
4
5import { Injectable } from '@angular/core';
6
7// import WebTorrent = require('webtorrent');
8declare var WebTorrent: any;
9
10@Injectable()
11export class WebTorrentService {
12 // private client: WebTorrent.Client;
13 private client: any;
14
15 constructor() {
16 this.client = new WebTorrent({ dht: false });
17 }
18
19 add(magnetUri: string, callback: Function) {
20 return this.client.add(magnetUri, callback);
21 }
22
23 remove(magnetUri: string) {
24 return this.client.remove(magnetUri);
25 }
26}