1

i'm using jplayer 2.1.0. i have 4 browsers chrome 22, opera 12, IE9 and mozilla firefox 15 all of which are latest browsers as of oct 2012. my player works in chrome but fails in all other browsers. i'm not using flash for now so just relying on HTML5. here's the code.

$(document).ready(function(){
            $("#jquery_jplayer_1").jPlayer({
                ready: function () {
                    var url;
                    $('.singles').click(function(event){
                        var x = event.target;
                        url = "http://localhost:8080/WebApplication1/songs/"+x.innerHTML;
                        $("#jquery_jplayer_1").jPlayer("setMedia",{
                            mp3: url
                        }).jPlayer("play");
                    });
                },
                swfPath: "/js",
                supplied: "mp3, oga"
            });
        });

i'm directly using the file path in the url..is this bad practice?
Should i send the mp3 file through the server? like setting the content type and everything?..sorry if being silly as i feel stupid about this myself

2

1 Answer 1

1

Refer the Following URL and download the Source then modify it according to your needs http://www.script-tutorials.com/how-to-play-audio-video-using-jplayer/

Since firefox and opera does not play mp3 files so modify the jquery call as follows

$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            mp3: "media/track.mp3",
            oga: "media/track.ogg"
        }).jPlayer("play");
    },
    ended: function (event) {
        $(this).jPlayer("play");
    },
    swfPath:"/swf",
    supplied: "mp3,oga",
    solution:"html,flash",
    wmode:"window"  
}); 
});

then add a ogg file of the same mp3 track inside the media folder.Use any convertors to convert mp3 file to ogg format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.