I have a component that plays an mp3 file, and it gets the name of the playback file from its parent. Here is the code:
export class PlayComponent implements OnChanges {
@Input() fileToPlay:string;
ngOnChanges(arg){
console.log(arg.fileToPlay);
}
}
and html:
<div *ngIf="fileToPlay!=''">
<audio controls autoplay class="playa" di="audio">
<source [src]="fileToPlay" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
It works great for the first game. The value fileToPlaycan be changed, and I want to play a new file in real-time, but he always plays the first file name.
How can i fix this?
source
share