Ionic Native Media how to play a list of file properly(javascript issue)

Dear expert,

I have a list of song


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 ='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;

I don’t know how to stop and release the previous song. Can anyone help?