以下代码在 IE9 和 Opera 中有效,但在 Firefox 中无效。
在 Firefox 中,我单击另一个链接并返回包含视频的页面。然后,视频开始播放。否则,视频不会开始播放(刷新页面时再次不会开始播放):
function output_video_URL(id, local_path_of_video, remote_path_of_video) {
var http_check = getHTTPObject();
var local_URL = local_server + local_path_of_video;
var remote_URL = remote_server + remote_path_of_video;
http_check.open("HEAD", local_path_of_video);
http_check.onreadystatechange = handleHttpResponse_check;
http_check.send(null);
function handleHttpResponse_check() {
if (http_check.readyState == 4){
if (http_check.status == 200) {
var video = document.getElementById(id);
video.src = local_URL;
video.parentNode.Filename = local_URL;
}
else if (http_check.status == 404) {
var video = document.getElementById(id);
video.src = remote_URL;
video.parentNode.Filename = remote_URL;
}
}
}
}
<object width="364" height="266" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="mediaplayer1">
<param name="Filename" value="filmler/canakkeleklipkucuk.wmv" />
<param name="AutoStart" value="True" />
<param name="ShowControls" value="false" />
<param name="ShowStatusBar" value="false" />
<param name="ShowDisplay" value="false" />
<param name="AutoRewind" value="false" />
<embed id = "canakkeleklip" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" width="320" height="240" src="filmler/canakkeleklipkucuk.wmv" autostart="True" showcontrols="false" showstatusbar="false" showdisplay="false" autorewind="false"> </embed>
</object>
<script type = "text/javascript"> output_video_URL('canakkeleklip', 'videos/canakkeleklipkucuk.wmv', 'filmler/canakkeleklipkucuk.wmv'); </script>
答案1
您使用 wmv 有什么特殊原因吗?您是否考虑过使用多个元素,为不同的浏览器提供不同的文件?
您可以通过 media.io 在线转换文件或下载工具来为您完成转换;我经常使用 Miro 视频转换器。