diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-11-08 20:49:43 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-11-08 20:49:43 +0100 |
commit | e31f6ad6373c70481bc5dc50bcd9691ef69b2c4b (patch) | |
tree | cf5a8b13babbc35be4e509f40a210fa31f81c5f8 /client/src/app | |
parent | 3bb2c7f99dd495adac8e486e98f135c183642381 (diff) | |
download | PeerTube-e31f6ad6373c70481bc5dc50bcd9691ef69b2c4b.tar.gz PeerTube-e31f6ad6373c70481bc5dc50bcd9691ef69b2c4b.tar.zst PeerTube-e31f6ad6373c70481bc5dc50bcd9691ef69b2c4b.zip |
Client: use videojs as player
Diffstat (limited to 'client/src/app')
3 files changed, 16 insertions, 7 deletions
diff --git a/client/src/app/videos/video-watch/video-watch.component.html b/client/src/app/videos/video-watch/video-watch.component.html index d75ed3538..0bbb5d3e8 100644 --- a/client/src/app/videos/video-watch/video-watch.component.html +++ b/client/src/app/videos/video-watch/video-watch.component.html | |||
@@ -16,7 +16,7 @@ | |||
16 | <div class="row"> | 16 | <div class="row"> |
17 | <div class="col-md-12"> | 17 | <div class="col-md-12"> |
18 | <div class="embed-responsive embed-responsive-19by9"> | 18 | <div class="embed-responsive embed-responsive-19by9"> |
19 | <my-loader [loading]="loading"></my-loader> | 19 | <video id="video-container" class="video-js vjs-default-skin vjs-big-play-centered"></video> |
20 | </div> | 20 | </div> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
diff --git a/client/src/app/videos/video-watch/video-watch.component.scss b/client/src/app/videos/video-watch/video-watch.component.scss index e1d9300cd..9d335c3ba 100644 --- a/client/src/app/videos/video-watch/video-watch.component.scss +++ b/client/src/app/videos/video-watch/video-watch.component.scss | |||
@@ -1,8 +1,6 @@ | |||
1 | my-loader { | 1 | #video-container { |
2 | display: block; | ||
3 | padding-top: 200px; | ||
4 | width: 100%; | 2 | width: 100%; |
5 | text-align: center; | 3 | height: 100%; |
6 | } | 4 | } |
7 | 5 | ||
8 | .embed-responsive { | 6 | .embed-responsive { |
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 1d5fd45ee..6012daa5c 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts | |||
@@ -3,6 +3,7 @@ import { ActivatedRoute } from '@angular/router'; | |||
3 | 3 | ||
4 | import { ModalDirective } from 'ng2-bootstrap/components/modal'; | 4 | import { ModalDirective } from 'ng2-bootstrap/components/modal'; |
5 | import { MetaService } from 'ng2-meta'; | 5 | import { MetaService } from 'ng2-meta'; |
6 | import * as videojs from 'video.js'; | ||
6 | 7 | ||
7 | import { Video, VideoService } from '../shared'; | 8 | import { Video, VideoService } from '../shared'; |
8 | import { WebTorrentService } from './webtorrent.service'; | 9 | import { WebTorrentService } from './webtorrent.service'; |
@@ -22,6 +23,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
22 | error: boolean = false; | 23 | error: boolean = false; |
23 | loading: boolean = false; | 24 | loading: boolean = false; |
24 | numPeers: number; | 25 | numPeers: number; |
26 | player: VideoJSPlayer; | ||
25 | uploadSpeed: number; | 27 | uploadSpeed: number; |
26 | video: Video = null; | 28 | video: Video = null; |
27 | 29 | ||
@@ -50,6 +52,16 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
50 | error => alert(error.text) | 52 | error => alert(error.text) |
51 | ); | 53 | ); |
52 | }); | 54 | }); |
55 | |||
56 | const videojsOptions = { | ||
57 | controls: true, | ||
58 | autoplay: false | ||
59 | }; | ||
60 | |||
61 | const self = this; | ||
62 | videojs('video-container', videojsOptions, function () { | ||
63 | self.player = this; | ||
64 | }); | ||
53 | } | 65 | } |
54 | 66 | ||
55 | ngOnDestroy() { | 67 | ngOnDestroy() { |
@@ -62,7 +74,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
62 | } | 74 | } |
63 | 75 | ||
64 | loadVideo() { | 76 | loadVideo() { |
65 | |||
66 | console.log('<iframe width="560" height="315" src="' + window.location.origin + '/videos/embed/' + this.video.id + '" frameborder="0" allowfullscreen></iframe>'); | 77 | console.log('<iframe width="560" height="315" src="' + window.location.origin + '/videos/embed/' + this.video.id + '" frameborder="0" allowfullscreen></iframe>'); |
67 | 78 | ||
68 | // Reset the error | 79 | // Reset the error |
@@ -86,7 +97,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
86 | this.loading = false; | 97 | this.loading = false; |
87 | 98 | ||
88 | console.log('Added ' + this.video.magnetUri + '.'); | 99 | console.log('Added ' + this.video.magnetUri + '.'); |
89 | torrent.files[0].appendTo(this.elementRef.nativeElement.querySelector('.embed-responsive'), (err) => { | 100 | torrent.files[0].renderTo('#video-container video', { autoplay: true }, (err) => { |
90 | if (err) { | 101 | if (err) { |
91 | alert('Cannot append the file.'); | 102 | alert('Cannot append the file.'); |
92 | console.error(err); | 103 | console.error(err); |