VLC网页插件添加对火狐浏览器的支持

1.用<embed>标签

下面这段代码只支持火狐,不支持IE

<html>
<title>CCTV 新闻</title>
<body>
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
       width="640"
       height="480"
       id="vlc">
</embed>
<script language="Javascript">

var vlc = document.getElementById("vlc");
var mrl="udp://@239.255.1.1:1234";
//将地址添加到播放列表
vlc.playlist.add(mrl);
//播放
vlc.playlist.play()

</script>
</body>
</html>

2.同时支持IE和火狐的代码

通过测试发现,IE8.0并不支持js代码中VLC插件的接口,版本1和2都不支持,但是火狐浏览器支持

<html>
<title>CCTV 新闻</title>
<body>

<!--将<embed>标签嵌入<object>标签内部之后可以同时兼容IE和火狐-->
<object classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" 
        width="640" height="480" events="True" id="vlc2"> 
	<param name="MRL" value="udp://@239.255.1.1:1234" /> 
	<param name="ShowDisplay" value="True" /> 
	<param name="Loop" value="False" /> 
	<param name="AutoPlay" value="True" /> 
		<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
			   width="640"
			   height="480"
			   id="vlc">
		</embed>
</object>

<script language="Javascript">

var vlc = document.getElementById("vlc");
var mrl="udp://@239.255.1.1:1234";
//将地址添加到播放列表
vlc.playlist.add(mrl);
//播放
vlc.playlist.play()

</script>
</body>
</html>

3.进一步精简的代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
	<head>
		<title>CCTV 新闻</title>
	</head>
	<body>
		<!--将<embed>标签嵌入<object>标签内部之后可以同时兼容IE和火狐-->
		<object classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" 
				codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" 
				width="640" 
				height="480" 
				events="True" 
				id="vlc2"> 
			<param name="MRL" value="udp://@239.255.1.1:1234" /> 
			<param name="ShowDisplay" value="True" /> 
			<param name="Loop" value="False" /> 
			<param name="AutoPlay" value="True" /> 
				<embed type="application/x-vlc-plugin" 
					   pluginspage="http://www.videolan.org"
					   width="640"
					   height="480"
					   src="udp://@239.255.1.1:1234"
					   id="vlc">
				</embed>
		</object>
	</body>
</html>


你可能感兴趣的:(VLC)