cordova-plugin-nativeaudio icon indicating copy to clipboard operation
cordova-plugin-nativeaudio copied to clipboard

completeCallback not getting called in "play" function

Open khushbu-mulani opened this issue 4 years ago • 1 comments

Hi,

I wish to play another audio on completion of the first one. For this, I have implemented a recursion function as such:

PlayAllList(i, length, audioArray) {
    var self = this;
    this.nativeAudio.preloadComplex('audio' + i, audioArray[i], 1, 1, 0).then(() => {
      console.log("Load success for audio", i)
      this.nativeAudio.play('audio' + i, () => {
        //COMPLETECALLBACK
        console.log('audio' + i + ' is done playing')
        self.nativeAudio.unload('audio' + i)
        if ((i + 1) == length) {
          console.log("done saying all the audios!! Hurray!!")
        } else {
          console.log("=====Calling the next audio=====")
          self.PlayAllList(i + 1, length, audioArray)
        }
      }).then(() => {
        //SUCCESSCALLBACK
        console.log("Success callback for play ", i)
      }, (err) => {
        //ERRORCALLBACK
        console.log("Error callback for play: ", err)
      })
    }, (loadError) => {
      console.log("========================loadError=========================== ", loadError)
    });
  }

But I cannot get "COMPLETECALLBACK" block running anytime even if the first audio is played successfully. Other blocks i.e. "SUCCESSCALLBACK" and "ERRORCALLBACK" seem to work perfectly fine.

Here my audioArray is an array of base64 strings like ["data:audio/mpeg;base64,UklGRmh6AgBXQVZFZm10IBAAAAABAAEAIlY......", "data:audio/mpeg;base64,UklGRmh6AAAAAABAAEAIlYAAESsAAACABAAZGF0YeSFAQAAAAAAAAAAAAAAAAA......"].

Any help would be very much appreciated. Thanks!

khushbu-mulani avatar Mar 23 '20 07:03 khushbu-mulani

Same error for me. Any idea?

arturomf avatar May 28 '20 14:05 arturomf