mirror of https://github.com/Chocobozzz/PeerTube
Client: use videojs as player
parent
3bb2c7f99d
commit
e31f6ad637
|
@ -32,6 +32,7 @@
|
|||
"@types/node": "^6.0.38",
|
||||
"@types/source-map": "^0.1.26",
|
||||
"@types/uglify-js": "^2.0.27",
|
||||
"@types/videojs": "0.0.30",
|
||||
"@types/webpack": "^1.12.29",
|
||||
"angular-pipes": "^4.0.0",
|
||||
"angular2-template-loader": "^0.6.0",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="embed-responsive embed-responsive-19by9">
|
||||
<my-loader [loading]="loading"></my-loader>
|
||||
<video id="video-container" class="video-js vjs-default-skin vjs-big-play-centered"></video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
my-loader {
|
||||
display: block;
|
||||
padding-top: 200px;
|
||||
#video-container {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.embed-responsive {
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||
|
||||
import { ModalDirective } from 'ng2-bootstrap/components/modal';
|
||||
import { MetaService } from 'ng2-meta';
|
||||
import * as videojs from 'video.js';
|
||||
|
||||
import { Video, VideoService } from '../shared';
|
||||
import { WebTorrentService } from './webtorrent.service';
|
||||
|
@ -22,6 +23,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
|||
error: boolean = false;
|
||||
loading: boolean = false;
|
||||
numPeers: number;
|
||||
player: VideoJSPlayer;
|
||||
uploadSpeed: number;
|
||||
video: Video = null;
|
||||
|
||||
|
@ -50,6 +52,16 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
|||
error => alert(error.text)
|
||||
);
|
||||
});
|
||||
|
||||
const videojsOptions = {
|
||||
controls: true,
|
||||
autoplay: false
|
||||
};
|
||||
|
||||
const self = this;
|
||||
videojs('video-container', videojsOptions, function () {
|
||||
self.player = this;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@ -62,7 +74,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
loadVideo() {
|
||||
|
||||
console.log('<iframe width="560" height="315" src="' + window.location.origin + '/videos/embed/' + this.video.id + '" frameborder="0" allowfullscreen></iframe>');
|
||||
|
||||
// Reset the error
|
||||
|
@ -86,7 +97,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
|||
this.loading = false;
|
||||
|
||||
console.log('Added ' + this.video.magnetUri + '.');
|
||||
torrent.files[0].appendTo(this.elementRef.nativeElement.querySelector('.embed-responsive'), (err) => {
|
||||
torrent.files[0].renderTo('#video-container video', { autoplay: true }, (err) => {
|
||||
if (err) {
|
||||
alert('Cannot append the file.');
|
||||
console.error(err);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
@import '../video.js/dist/video-js.css';
|
||||
|
||||
body {
|
||||
padding: 20px;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"node",
|
||||
"source-map",
|
||||
"uglify-js",
|
||||
"videojs",
|
||||
"webpack"
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue