WonderPlugin Audio Player JavaScript API

This post will show you how to use JavaScript to control the WonderPlugin Audio Player.

The following JavaScript will play the audio:

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

In the above code, 1 is the id of the audio player. wonderpluginaudio-1 is the id of the created player DIV.

If the id of your player is 2, you need to change the id value accordingly:

jQuery("#wonderpluginaudio-2").data("object").playAudio();

To pause the player:

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

The function audioRun(index, autoplay) will jump to the specified audio. The index starts from 0. For example, the following function will jump to the second audio and play it:

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

To goto the previous audio:

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

To goto the next audio:

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

The following four text links will play, pause, jump to the second audio and jump to the fifth audio in the following player:

<a onclick='jQuery("#wonderpluginaudio-1").data("object").playAudio();'>Click to Play</a>

<a onclick='jQuery("#wonderpluginaudio-1").data("object").pauseAudio();'>Click to Pause</a>

<a onclick='jQuery("#wonderpluginaudio-1").data("object").audioRun(1, true);'>Jump to Second Audio and Play</a>

<a onclick='jQuery("#wonderpluginaudio-1").data("object").audioRun(4, true);'>Jump to Fifth Audio and Play</a>

The demo is as following:

Click to Play
Click to Pause
Jump to Second Audio and Play
Jump to Fifth Audio and Play

Remove track numbers in audio player playlist

Question:

Is there a way to get rid of the track numbers in the audio player playlist?

Answer:

In step 3, Options tab, click Advanced Options button, enter the following code to the Data Options field:

data-tracklistitemformat="%TITLE% <span style='position:absolute;top:0;right:0;'>%DURATION%</span>"

The demo is as following:

Multiple jQuery loaded in WordPress

Question:

I have a website in progress, I used Wonderplugin for WordPress and as I came across on the development, I cannot get it working.

I already uploaded images and configured everything on WordPress.

I also copied the shortcode to the php page that I am working on. But the carousel does not show up.

Answer:

Normally this problem is that there are multiple jQuery files added to your WordPress.

You can view the HTML source code of your webpage, and check how many jQuery are added in your website. In Google Chrome, you can view the HTML source code with menu View -> Developer -> View Source, then search text "jquery" in the source code.

There should be only one jQuery in the webpage, which is added by the WordPress system.

Some plugins add their own jQuery to the website, and this is not correct. A plugin should always use the system installed jQuery, and the js files added from a plugin will be added after the system jQuery.

A jQuery will destroy all other jQuery functions that are added before it. So if a plugin adds its own jQuery, it may destroy other jQuery functions.

To fix the issue:

In the plugin, Setting menu, you can try to check the option "Add plugin js scripts to the footer". This option will place the plugin js file to the footer and will fix the problem in most cases.

If the above option is not working, you can try to disable all other plugins and see whether the WonderPlugin works. If it works, you can then enable the plugins one by one, and find the plugin that has caused the problem.

If WonderPlugin is still not working after you have disabled all other plugins, then the extra jQuery may have been added manually to the theme or the page, you need to find the code and remove it.

Not all audio files loading in Google Chrome

Question:

I purchased the commercial version of your audio plugin this morning and installed it on a client’s site who uses quite a few audio files. One page in particular contains 10 different audio files. I’m having a problem “loading” the last three audio files in Google Chrome on both a mac and pc. All the audio files work great in IE, Safari, and Firefox. They actually work fine on the chrome mobile application too.

Is there a setting that I need to change to get all the files to load when the page loads in Chrome?

Answer:

The problem is because Chrome has a maximum connection limit of html5 audios.

To fix the problem, in step 3, Options tab, Advanced Options, enter the following text to the Advanced Options tab:

data-preloadaudio="false"

With this change, the player will only load the mp3 file when required, and it will fix the problem.