diff options
Diffstat (limited to 'client/angular/videos/components/watch')
3 files changed, 52 insertions, 0 deletions
diff --git a/client/angular/videos/components/watch/videos-watch.component.html b/client/angular/videos/components/watch/videos-watch.component.html new file mode 100644 index 000000000..e47222751 --- /dev/null +++ b/client/angular/videos/components/watch/videos-watch.component.html | |||
@@ -0,0 +1,2 @@ | |||
1 | <div class="embed-responsive embed-responsive-19by9"> | ||
2 | </div> | ||
diff --git a/client/angular/videos/components/watch/videos-watch.component.scss b/client/angular/videos/components/watch/videos-watch.component.scss new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/client/angular/videos/components/watch/videos-watch.component.scss | |||
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts new file mode 100644 index 000000000..e3a973820 --- /dev/null +++ b/client/angular/videos/components/watch/videos-watch.component.ts | |||
@@ -0,0 +1,50 @@ | |||
1 | /// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' /> | ||
2 | |||
3 | import { Component, OnInit, ElementRef } from 'angular2/core'; | ||
4 | import { RouteParams } from 'angular2/router'; | ||
5 | |||
6 | declare var WebTorrent: any; | ||
7 | |||
8 | import { Video } from '../../models/video'; | ||
9 | import { VideosService } from '../../services/videos.service'; | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-video-watch', | ||
13 | templateUrl: 'app/angular/videos/components/watch/videos-watch.component.html', | ||
14 | styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ] | ||
15 | }) | ||
16 | |||
17 | export class VideosWatchComponent { | ||
18 | video: Video; | ||
19 | |||
20 | private client: any; | ||
21 | |||
22 | constructor( | ||
23 | private _videosService: VideosService, | ||
24 | private _routeParams: RouteParams, | ||
25 | private _elementRef: ElementRef | ||
26 | ) { | ||
27 | this.client = new WebTorrent({ dht: false }); | ||
28 | } | ||
29 | |||
30 | ngOnInit() { | ||
31 | let id = this._routeParams.get('id'); | ||
32 | this._videosService.getVideo(id).subscribe( | ||
33 | video => this.loadVideo(video), | ||
34 | error => alert(error) | ||
35 | ); | ||
36 | } | ||
37 | |||
38 | loadVideo(video: Video) { | ||
39 | this.video = video; | ||
40 | |||
41 | this.client.add(this.video.magnetUri, (torrent) => { | ||
42 | torrent.files[0].appendTo(this._elementRef.nativeElement, (err) => { | ||
43 | if (err) { | ||
44 | alert('Cannot append the file.'); | ||
45 | console.error(err); | ||
46 | } | ||
47 | }) | ||
48 | }) | ||
49 | } | ||
50 | } | ||