我从 Twitch 获取流并通过 jQuery 动态更新流信息。它适用于 Firefox,但不适用于 Chrome / IE。
Javascript:
$(function() {
var streamer = $("#stream-list ul li.active").first().attr("id");
$("#live_embed_player_flash").attr("data", "http://sv.twitch.tv/widgets/live_embed_player.swf?channel=" + streamer);
$("#flashvars").val("hostname=sv.twitch.tv&channel=" + streamer + "&auto_play=true&start_volume=0");
$("#stream-list ul li").click(function(){
$("#stream-list ul li.active").first().removeClass("active");
$(this).addClass("active");
var streamer = $(this).attr("id");
$("#live_embed_player_flash").attr("data", "http://sv.twitch.tv/widgets/live_embed_player.swf?channel=" + streamer);
$("#flashvars").val("hostname=sv.twitch.tv&channel=" + streamer + "&auto_play=true&start_volume=25");
});
});
HTML:
<ul>
<li class="active" id="name-of-stream"></li>
<li></li>
<li></li>
</ul>
<div id="player">
<object type="application/x-shockwave-flash" height="480" width="720" id="live_embed_player_flash" data="" bgcolor="#000000">
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="allowNetworking" value="all" />
<param name="movie" value="http://sv.twitch.tv/widgets/live_embed_player.swf" />
<param name="flashvars" value="" />
</object>
</div>
如果您想要示例链接,请点击此链接 (http://icguides.com/)!