Search code examples
jqueryswfobjectjwplayer

JW Player in IE9 won't load and play MP3 file


It's quite simple, I have a list of links, and if a user clicks a link a div gets loaded with some content (jwplayer placeholder and song title) and the jwplayer should startup. This is my javascript (jquery and jquery-swfobject):

$(function() {
    $('.song a').live('click', function() {
        var title = $(this).find('span.title').text();
        var file = $(this).attr('href');
        $.ajax({
            type: 'POST',
            url: $('.songlocation').html(),
            data: 'name=' + title + '&file=' + file,
            success: function(html) {
                $('.songplayer').attr('title', title);
                $('.songplayer').html(html);
            },
            complete: function(request, status) {
                $('#mediaspace').flash({
                    swf: $('.flashlocation').html(),
                    allowfullscreen: true,
                    allowscriptaccess: 'always',
                    wmode: 'opaque',
                    width: 238,
                    height: 24,
                    flashvars:
                        {
                            file: file,
                            autostart: true
                        }
                });

                if ($('#mediaspace').text().indexOf("Flash is disabled") == -1) {
                    $('.songplayer').show();
                } else {
                    document.location = file;
                }
            }
        });
        return false;
    });
});

$('.songlocation') contains /Home/SongPlayer

/Home/SongPlayer contains:

<div id="mediaspace">
    Flash is disabled
</div>

<div id="name">
    Song Title
</div>

<a href="http://url/to.mp3" class="download">Download MP3 &gt;&gt;</a>

This works perfectly fine in Opera/Firefox/Chrome/IE7/IE8, but not in IE9 The jwplayer loads just fine, but not the song. So the MP3 file is never being called in IE9


Solution

  • It seems the problem is the jquery-swfobject plugin. I have replace the jquery version of swfobject (old one) by swfobject 2.0 and now it is working fine.