Playing Sequentially audio files (Ionic 3 Native Audio)

0
down vote
favorite
I need to play a list of audio files one after another in Ionic 3

and i’m using ionic native audio plugin

playAll() {
    for (let i = 1; i <= 77; i++) {
      this.playAvecIonNative(i)
    }
  }

async playAvecIonNative(i) {
    // this.currentBeyit = this.cpt;
    this.idAudio = 'w' + i;
    this.nativeAudio.preloadComplex(this.idAudio, 'assets/audio/' + i + '.ogg', 1, 1, 0)
      .then(await this.onSuccessPreloading, this.onErrorPreload);
  }

  onSuccessPreloading = (data) => {
    this.scrollTo(i - 1);
    this.nativeAudio.play(this.idAudio).then(await this.onSuccessPlaying, this.onErrorPlay);
  }

  onSuccessPlaying = (a) => {
    this.nativeAudio.unload(this.idAudio);
  }

  onErrorPreload() {
    alert('ERREUR PRELOAD')
  }

  onErrorPlay() {
    alert('ERREUR PLAY')
  }

When i test with one audio file with the playAvecIonNative() it works great but for multiple file it doesn’t work as expected

Could you help me to achieve that ! Please !

It’s a bug with the plugin

The problem is on the callback wich execute at the same time when playing audio file.

Did this get fixed? Did you get it to work/report it?

1 Like

I need this as well. Nothing is working.
Any updates on how to accomplish this? Playing one short .mp3 after another.

All of my files play all at once, like a jumbled mess.

Thanks.

Hi @aboutwd,

I don’t think this has been fix.
You’ll have to make the preloaded sounds wait until.the previous sound has ended. Maybe consider using g a music/media controller to play the sou d sequential or make a function on your own.

Good luck!