I have a video streaming application that switches between different channels using jQuery to update Flash player parameters. The functionality works perfectly in Firefox, but I’m experiencing issues with Chrome and Internet Explorer where the Flash object doesn’t refresh properly when I change the data attribute.
JavaScript Code:
$(document).ready(function() {
var currentChannel = $("#channel-selector .selected").first().attr("data-channel");
$("#video_player_object").attr("data", "https://player.example.com/flash_player.swf?stream=" + currentChannel);
$("#player_params").val("server=player.example.com&stream=" + currentChannel + "&autoplay=true&volume=0");
$("#channel-selector .channel-item").click(function(){
$("#channel-selector .selected").removeClass("selected");
$(this).addClass("selected");
var newChannel = $(this).attr("data-channel");
$("#video_player_object").attr("data", "https://player.example.com/flash_player.swf?stream=" + newChannel);
$("#player_params").val("server=player.example.com&stream=" + newChannel + "&autoplay=true&volume=50");
});
});
HTML Structure:
<div id="channel-selector">
<div class="channel-item selected" data-channel="main-broadcast"></div>
<div class="channel-item" data-channel="secondary-stream"></div>
<div class="channel-item" data-channel="backup-feed"></div>
</div>
<div id="video-container">
<object type="application/x-shockwave-flash" height="600" width="800" id="video_player_object" data="" bgcolor="#000000">
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="wmode" value="transparent" />
<param name="movie" value="https://player.example.com/flash_player.swf" />
<param name="flashvars" value="" id="player_params" />
</object>
</div>
Any suggestions on how to make this cross-browser compatible?