vimeo player in angular
import { Component, ViewChildren } from '@angular/core';
import Player from "@vimeo/player";
@Component({
selector: 'player-component',
templateUrl: 'player.html'
})
export class PlayerComponent {
private player: Player;
@ViewChildren('player_container') playerContainer;
ngAfterViewInit() {
/* wait DOM be available */
this.playerContainer.changes.subscribe(item => {
if (this.playerContainer.length) {
/* DOM AVAILABLE */
this.player = new Player(this.playerContainer.first.nativeElement);
this.player.on('play', function() {
console.log('played the video!');
});
this.player.getVideoTitle().then(function(title) {
console.log('title:', title);
});
}
})
}
}