2011-03-22 202 views
0

当通过JS访问QuickTime的似乎只有一个办法让媒体在IOS版本大于4.2自动播放,如通过这里用户bhup:How can I autoplay media in iOS >= 4.2.1 Mobile Safari?媒体自动播放:如何使用iframe自动播放

var ifr=document.createElement("iframe"); 
ifr.setAttribute('src', "http://mysite.com/myvideo.mp4"); 
ifr.setAttribute('width', '1px'); 
ifr.setAttribute('height', '1px'); 
ifr.setAttribute('scrolling', 'no'); 
ifr.style.border="0px"; 
document.body.appendChild(ifr); 

使用此方法有一个主要缺点:我无法找到一种方法来使用此方法时,JS与Quicktime插件交互。

我已经尝试了很多东西,但不能找到一种方法,都在它暴露给JS的方式实例化插件,并有自动播放。有什么想法吗?

回答

0

方式一:

在您的IFRAME元素,设置onload="parent.someFunction();"

然后,在someFunction():

pluginElement = document.getElementById('yourIframeElementId').contentWindow.document.body.firstChild; 
pluginElement.GetTime(); //Or any other function that the QT plugin exposes