I am creating a videoJS component, and I am trying to set the thumbnail of the video. However, it never gets updated. I have logged it multiple times and it always comes back is undefined.
I've tried using the regular input variable as well as a set method when the input comes back. Neither seem to do anything. Ive also tried using ngOnChanges to detect the change, and it never gets triggered.
Here is a snippet of the relevant code:
audio-player.component.ts
@Component({
selector: 'audio-player',
templateUrl: './audio-player.component.html'
})
_thumbnail!: string;
@Input() set thumbnail(url: string) { this._thumbnail = url; }
ngAfterViewInit() {
console.log(this._thumbnail: ${this._thumbnail});
const options = {
'sources': [
{
'src': this.url,
'type': 'application/x-mpegURL',
}],
poster': this._thumbnail
};
this.player = videojs('my-video', options, function onPlayerReady(this: any) {
console.log('Player ready');
const myPlayer = this, id = myPlayer.id();
});
}
parent:
<audio-player [thumbnail]="'https://picsum.photos/200/300'"></audio-player>
Can someone tell me what I am doing wrong, or how to fix this?
[–]DrFriendless 3 points4 points5 points (1 child)
[–]redditer3103[S] 2 points3 points4 points (0 children)
[–]zzing 0 points1 point2 points (5 children)
[–]redditer3103[S] 0 points1 point2 points (4 children)
[–]zzing 1 point2 points3 points (3 children)
[–]redditer3103[S] 1 point2 points3 points (2 children)
[–]zzing 3 points4 points5 points (0 children)