Created
September 5, 2018 22:55
-
-
Save israeljrs/b020e2ce87f1dce6bec03c4a781604d5 to your computer and use it in GitHub Desktop.
Arquivo de exemplo para o artigo angular 6 com Video.JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, AfterViewInit, ViewChild, ElementRef } from '@angular/core'; | |
// Declara a lib do videojs como externa ao angular | |
declare let videojs: any; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.scss'] | |
}) | |
export class AppComponent implements AfterViewInit { | |
// Titulo do component | |
title = 'Player com Video.JS'; | |
// Instancia do video.js. | |
vidObj: any; | |
// Poster para ser usado no video.js | |
poster = '//d2zihajmogu5jn.cloudfront.net/elephantsdream/poster.png'; | |
// URL do video a ser reproduzido. | |
video = '//d2zihajmogu5jn.cloudfront.net/elephantsdream/ed_hd.mp4'; | |
// Acessa o elemento video do html5 via viewchild. | |
@ViewChild('myvid') vid: ElementRef; | |
ngAfterViewInit() { | |
const options = { | |
controls: true, | |
autoplay: false, | |
preload: 'auto', | |
techOrder: ['html5'] | |
}; | |
this.vidObj = new videojs(this.vid.nativeElement, options, function onPlayerReady() { | |
videojs.log('Your player is ready!'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment