How to loop sound using ionic-native@native-audio


#1

I am making the simple game app using ionic.
In the app When i get 5 coins,it should repeat sound effect 5 times.
I tried to do it myself but I could not find the solution.
Code snippet:

async repeatSoundFixedTime(source,repeat){
    var cur_repeat = 0;
    var done = false;
    var isPlaying = false;
    while(!done){
      if(isPlaying) continue;
      isPlaying = true;
      console.log('audio is playing now.');
      this.nativeAudio.play('coinsound',() => {
          cur_repeat ++;
          isPlaying = false;
          if(cur_repeat == repeat) 
            done = true;
      });
    }
  }

But it did not work.
How can i solve this problem?