如何动态更改 iOS 5 的 HTML5 .webm 文件?
我正在尝试使用 javascript 更改 iOS 5 上浏览器中的视频文件。
这是一张图像,当用户单击时,它将调用 ChangeVideo 函数,
<table class=ControlLeft>
<tr><td colspan=1 class=GroupLabel>aaa</td></tr>
<tr>
<td class=MovieButton id=Cslide6><a href="#" onclick="ChangeVideo('Fire-presentation/m_slide1.webm')"><img class=ThumbImage src="Fire-presentation/thumbnails/slide6.png" alt="slide6"></a></td>
</tr>
</table>
这是一个包含 .webm 文件的 div 元素,
<div id=container class=Container>
<video src=""Fire-presentation/m_slide1.webm" type="video/webm">
</video>
</div>
我使用了以下内容脚本删除容器中的 HTML 内容,并创建一个新的视频元素。
function ChangeVideo(path)
{
var container = document.getElementById("container");
container.innerHTML = "";
var myVideo = document.createElement("video");
myVideo.src = path;
myVideo.type = "video/webm";
container.appendChild(myVideo);
myVideo.load();
myVideo.play();
}
它可以在我的装有 Chrome 和 Firefox 的电脑上运行,但不能在装有 iOS 5.0.1 的 iPad 2 上运行,我这样做了 http://clubajax.org/ipad-bug-fix- for-dynamically-created-html5-video/ 和 http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/ControllingMediaWithJavaScript/ControllingMediaWithJavaScript.html#//apple_ref/doc/uid/TP40009523-CH3-SW5 建议但都不起作用。
是否可以在 iPad 2 中动态地将当前播放的视频更改为另一个视频? 谢谢 !
I'm trying to use javascript to change the video file in browser on iOS 5.
Here is a image, when user click, it will call ChangeVideo function,
<table class=ControlLeft>
<tr><td colspan=1 class=GroupLabel>aaa</td></tr>
<tr>
<td class=MovieButton id=Cslide6><a href="#" onclick="ChangeVideo('Fire-presentation/m_slide1.webm')"><img class=ThumbImage src="Fire-presentation/thumbnails/slide6.png" alt="slide6"></a></td>
</tr>
</table>
and here is a div element which contains a .webm file,
<div id=container class=Container>
<video src=""Fire-presentation/m_slide1.webm" type="video/webm">
</video>
</div>
I used the following script to remove HTML content in the container, and create a new video element.
function ChangeVideo(path)
{
var container = document.getElementById("container");
container.innerHTML = "";
var myVideo = document.createElement("video");
myVideo.src = path;
myVideo.type = "video/webm";
container.appendChild(myVideo);
myVideo.load();
myVideo.play();
}
It works on my PC with Chrome and Firefox, but doesn't work on iPad 2 with iOS 5.0.1 , I did as
http://clubajax.org/ipad-bug-fix-for-dynamically-created-html5-video/
and
http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/ControllingMediaWithJavaScript/ControllingMediaWithJavaScript.html#//apple_ref/doc/uid/TP40009523-CH3-SW5 suggest but neither works.
Is that possible to change the current playing video to another one in iPad 2 dynamically ?
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是这样,但是 iOS 不支持 .webm,因此无论您做什么,它都不适用于这些特定视频。
It possibly is, but iOS doesn't support .webm so it's not going to work with those particular videos whatever you do.