WPAudio WordPress Plugin Crashes Safari Browser When Song is Played From Post

Filed July 3rd, 2011 under Tutorial and WordPress

I encountered a problem on my music blog SalaciousSound today. I use a plugin called wpaudio, which uses javascript and the soundmanager2 library (with flash fallback) to play mp3 audio files. I was finding that, on a particular post, whenever I played an mp3 the browser would crash. The plugin was working fine on all other posts, so I knew that this had something to do with the number of mp3 files on this particular post.

How to reproduce the crash

Create a post with more than 20+ mp3s to play, or go to a page (archive for example) where more than 20+ players are present – it doesn’t matter if they’re all inline or each have their own wpaudio markup, you just need more than twenty players. The crash was occurring in Safari. Chrome was working ok. I didn’t test Firefox or Internet Explorer.

I have a monthly series that I run called the Monthly Best of the Blogosphere, wherein I post 25-30 tracks that have been really popular that month. Only on these posts was the browser crash occurring.

How to fix the crash

You have to edit the wpaudio.js (or wpaudio.min.js file, depending on what you use – I use the minified wpaudio.min.js file myself). You have to change two lines of code in this file, and add an additional one. It’s pretty easy, and if you follow my instructions carefully you can do this with minimal coding knowledge.

Find this function:

function WpaudioHTML5 (parent) {
			...
}

Find these two lines – they are sequential:

start = player.seekable.start();
end = player.seekable.end();

Change them to this:

start = player.buffered.start();
end = player.buffered.end();

Next, find these two lines:

player.src = parent.getUrl();
player.volume = 1;

And add this line after them:

player.preload = "none";

Voila! Problem solved!

Cailen
Cailen lives in Toronto. He is passionate about music and coffee culture, photography and videography, and code efficiency.

Leave a Reply