Skip to content

Instantly share code, notes, and snippets.

@israeljrs
Created September 5, 2018 22:55
Show Gist options
  • Save israeljrs/b020e2ce87f1dce6bec03c4a781604d5 to your computer and use it in GitHub Desktop.
Save israeljrs/b020e2ce87f1dce6bec03c4a781604d5 to your computer and use it in GitHub Desktop.
Arquivo de exemplo para o artigo angular 6 com Video.JS
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