smnbbrv / ngx-plyr

Angular 6+ binding for Plyr video & audio player
https://smnbbrv.github.io/ngx-plyr/
MIT License
100 stars 65 forks source link

*ngIf with ngx-plyr #22

Closed bradrice closed 4 years ago

bradrice commented 5 years ago

I stere a way to show and hide the ngx-plyr component based upon some variable? I have an hasAudio boolean that I am using and when I do I get errors when I try to start the audio on plyrCanPlay.

<div *ngIf="hasAudio" mat-card-image plyr plyrTitle="Audio" plyrType="audio" [plyrPlaysInline]="true" [plyrCrossOrigin]="false" [plyrSources]="audioSources"></div>

this.playSub = this.plyr.plyrCanPlay.subscribe((data)=> { console.log('Ready to play'); this.play(); });

ERROR TypeError: Cannot read property 'plyrCanPlay' of undefined

smnbbrv commented 5 years ago

Why don’t you just use (plyrCanPlay)=“yourfunc($event)”?

bradrice commented 5 years ago

That looks cool. How do I make the player play using that? this.target.play() doesn't work.

bradrice commented 5 years ago

(plyrCanPlay)="myfunc($event)" never fires. What do I need to do?