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