【问题标题】:listening to radio streaming from the web收听网络上的广播流
【发布时间】:2011-11-09 15:40:15
【问题描述】:

我尝试通过按第一个结果不是收音机声音来收听来自网络的流媒体广播,当我将url地址输入函数play_radio时是否有任何错误。当我单击第二个按钮时,我设法收听了广播,但没有收听网络上的 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>

【问题讨论】:

  • play_radio() 函数不执行任何操作。它只是一个字符串文字。您必须将该 HTML 插入页面上的某个位置,以便浏览器对其进行解析。

标签: php html streaming radio windows-media-player


【解决方案1】:

你需要让它输出代码,我不知道播放器/对象是否会按预期工作,但这是你代码中的主要问题,所以你需要添加 document.write 或任何其他方式来输出该代码:

<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>

【讨论】:

    猜你喜欢
    • 2020-10-07
    • 2016-08-28
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 2012-12-21
    • 2012-11-02
    • 2011-01-14
    • 1970-01-01
    相关资源
    最近更新 更多