2011-09-03 52 views
0

我试图通过按第一个结果收听来自网络的流式广播不是广播语音,当我向play_radio函数输入url地址时是否有任何错误。当我点击第二个按钮时,我设法收听收音机,但不能从网络上的Windows媒体播放器收听。从网络收听广播流

你能帮我找到函数play_radio的错误吗?谢谢。

<html> 
<head> 
<script type="text/javascript"> 
    function play_radio(url) 
    { 
     '<object style="float: right;" classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" width="220" height="50" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">'+"\n"+ 
     '<param name="align" value="center" />'+"\n"+ 
     '<param name="url" value="'+url+'" />'+"\n"+ 
     '<param name="src" value="'+url+'" /><embed style="float: right;" type="application/x-mplayer2" width="220" height="50" src="'+url+'" url="'+url+'" align="center"></embed></object>' 
    } 
</script> 
</head> 

<body> 
<table style="margin-left: auto; margin-right: auto;" border="1" cellspacing="1" cellpadding="10" align="center"> 
<tbody> 
<tr> 
<td><input type="button" value="radio 1" onclick="play_radio('http://www.elshinta.com/v2003a/elsh_streaming.asx')" /></td> 
<td><input onclick="window.location.href='http://www.elshinta.com/v2003a/elsh_streaming.asx'" type="BUTTON" value="radio 2" /></td> 
</tr> 
</tbody> 
</table> 

</body> 
</html> 
+0

'play_radio()'函数不会执行任何操作。这只是一个字符串文字。您必须将该HTML插入页面上的某个位置,以供浏览器解析。 – JJJ

回答

1

你需要使它输出的代码,玩家/对象是否会如预期,我不知道,但是这是在你的代码的主要问题,所以你需要添加文件撰写或任何其他输出该代码的方法:

<script type="text/javascript"> 
    function play_radio(url) 
    { 
     document.write('<object style="float: right;" classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" width="220" height="50" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">'+"\n"+ 
     '<param name="align" value="center" />'+"\n"+ 
     '<param name="url" value="'+url+'" />'+"\n"+ 
     '<param name="src" value="'+url+'" /><embed style="float: right;" type="application/x-mplayer2" width="220" height="50" src="'+url+'" url="'+url+'" align="center"></embed></object>'); 
    } 
</script>