Search code examples
javascriptjplayer

Cannot get jPlayer to give me sound anymore


It used to, and i dont know why it doesnt now. Anyway my JS is as follows:

$(document).ready(function(){
    var $container = $('#soundboard');

    $("#jplayer").jPlayer({
        supplied: "mp3",
        wmode: "window"
    });


    $("a.playbutton").click(function(e) {
        var current = $("#jplayer").data().jPlayer.status.src
        var playing = current.split("/");
        var href = encodeURIComponent($(this).attr("href"));

        if(playing[3] != href) {


            console.log("href:" + href);
            console.log("playing:" + playing);
            console.log("current:" + current);

            $("#jplayer").jPlayer("setMedia", {mp3: "http://mp3.mydomain.net/" + href});
            $("#jplayer").jPlayer("play");

            $("a.playbutton").removeClass("stop");
            $(this).addClass('stop');

            $("a.playbutton > img").each(function () {
                $(this).attr("src","http://i.mydomain.net/icons/play.png"); 
            });
        } else {
            $("#jplayer").jPlayer("stop");
            $("#jplayer").jPlayer("clearMedia");
            $("a.playbutton").removeClass("stop");
        }
        return false;
    });
});   

Last time I checked this page it worked fine, and for some reason it's gone. I updated my jplayer.js file with jquery.jplayer.min.js.

The HTML is:

<a href='mymp3.mp3' class='playbutton'></a>

The filenames are correct, the variables seem correct, however no audio is playing at all. I don't get any error messages either, the pictures all change nicely too as seen from the JS. I just have nothing to work with as there are no error messages :(

Edit: This is a chrome specific error. The player is working fine in internet explorer.


Solution

  • Apparently the latest stable version of Chrome broke html5 audio for jPlayer because jPlayer is using a non-standard mimetype for mp3 files.

    See this: https://code.google.com/p/chromium/issues/detail?id=386073

    Fix here but it requires editing the jplayer javascript file: https://github.com/happyworm/jPlayer/issues/223

    Around line 704 (in version 2.6.3) change to:

    mp3: {
      //codec: 'audio/mpeg; codecs="mp3"',
      codec: 'audio/mpeg',
      flashCanPlay: true,
      media: 'audio'
    },
    

    Update:

    Fixed in latest version of jPlayer: https://cdnjs.cloudflare.com/ajax/libs/jplayer/2.6.4/jquery.jplayer/jquery.jplayer.min.js