Amazing Audio Player API and Events

With Amazing Audio Player API and events, you can execute your own JavaScript when a player event occurs, like when an audio plays or pauses.

In the following code snippet, amazingaudioplayer-1 is the id of the player DIV. If you have specified a different audio player ID in the Publish dialog, you need to change the number accordingly.

All codes can only be executed after the jQuery document is ready.

Events:

jQuery(document).ready(function(){

  jQuery("#amazingaudioplayer-1").bind("amazingaudioplayer.played", function(event, index){
    console.log(index);
  });

  jQuery("#amazingaudioplayer-1").bind("amazingaudioplayer.paused", function(event, index){
    console.log(index);
  });

  jQuery("#amazingaudioplayer-1").bind("amazingaudioplayer.stopped", function(event, index){
    console.log(index);
  });

  jQuery("#amazingaudioplayer-1").bind("amazingaudioplayer.playprogress", function(event, data){
    console.log(data);
    console.log(data.current);
    console.log(data.duration);
  });

  jQuery("#amazingaudioplayer-1").bind("amazingaudioplayer.switched", function(event, data){
    console.log(data);
    console.log(data.previous);
    console.log(data.current);
  });
});

API to play, pause and stop audio:

jQuery(document).ready(function(){

  jQuery("#amazingaudioplayer-1").data("object").playAudio();

  jQuery("#amazingaudioplayer-1").data("object").pauseAudio();

  jQuery("#amazingaudioplayer-1").data("object").stopAudio();

});

API to goto a specified audio and play:

jQuery("#amazingaudioplayer-1").data("object").audioRun(index, autoplay);

The index starts from 0. The following snippet will goto the second audio and play:

  jQuery("#amazingaudioplayer-1").data("object").audioRun(1, true);

To goto the previous audio, using the following code:

  jQuery("#amazingaudioplayer-1").data("object").audioRun(-2, true);

To goto the next audio, using the following code:

  jQuery("#amazingaudioplayer-1").data("object").audioRun(-1, true);