How to stop media plugin audio when navigating away from a page

Hello, I am playing audios in an ionic app with cordova media plugin.

so, when users navigate a way from the audio page, I want the audio to stop because it’s causing an unexpected behaviour that allows users to play multiple audios at the same time thereby causing overlap of audios .

This is what I have tried that did not work

ngOnDestroy(): void {
   
    if(this.Audiofile){
      //this.Audiofile.stop()
     this.Audiofile.release()
      }
   
  }
  ionViewDidLeave(){
   
    if(this.Audiofile){
    //this.Audiofile.stop()
    this.Audiofile.release()
    }
  }
  ionViewWillLeave(){
  
    if(this.Audiofile){
    //this.Audiofile.stop()
    this.Audiofile.release()
    }
  }

Are you using tabs, by any chance?

Thank you, yes I am using tabs

Then you’re going to have to listen for tab changes on the <ion-tabs>. Its children are cached - they don’t get destroyed.

Thank you, any hint on how to go about that ?

onTabChange() {
       
    }

?