Syamsul 'isul' Arifin

kartunis dan desainer

Wed, Oct 20, 2021

How to Make Sound Looping in Cordova

cordova-plugin-media loop

Sometimes we need the sound looping in our app. Usually it’s for background sound. In Cordova, we use cordova-media-plugin callback.

Of course, first we must install cordova-media-plugin. Then, add a conditional in callback status. Below is the example.

var backSound= new Media(src, function(err){
  console.log(err)
}, function(status){
  if (status == 4){
    this.play()
  }
});

backSound.play();
comments powered by Disqus