Dear expert,
I have a list of song
song1
song2
song3
…
When user tap song1, I play song1.mp3. If user tap song2 before song1 finishes, I’d like to stop song 1 and start playing song2. My question is how to do it without memory leaking.
I tried:
play(song) {
```
const file: MediaObject = this.media.create('song');
// to listen to plugin events:
file.onStatusUpdate.subscribe(status => console.log(status)); // fires when file status changes
file.onSuccess.subscribe(() => console.log('Action is successful'));
file.onError.subscribe(error => console.log('Error!', error));
// play the file
file.play();
```
}
I don’t know how to stop and release the previous song. Can anyone help?