I’m using the Media plugin to play some audios.
When the audio has the status of running or playing, i change the property init to change the name of the icon i want to display.
It works the first time i click, changes the icon to “pause”.
But when the audio changes the status to stopped, or the audio just finished, even if i can see in the logs, that object changed correctly the value, in the view never happens, and I’m going crazy because I dont’ understand why its not working.
this.file = this.media.create(url);
this.file.play();
this.file.onStatusUpdate.subscribe(status => {
console.log("AUDIO STATUS", status);
if (status == 1 || status == 2) {
this.chistesFiltered[i].init = "pause"
}
if (status == 4) {
this.chistesFiltered[i].init = "play"
console.log("item", item)
}
})
this.file.onSuccess.subscribe(() => {
console.log("Audio Completed");
console.log("item2", this.chistesFiltered[i].init)
this.chistesFiltered[i].init = "play";
this.file.release();
});
Also this is my view
I have an ngFor, the alias for the array its “item”
<ion-col col-3 center text-center>
<button ion-button large round (click)="playPause(item,i)">
<ion-icon name="{{item.init}}"></ion-icon>
</button>
</ion-col>
Thanks all.