Search code examples
javascriptiosquicktimeautoplay

Media autoplay in iOS 4.2+: How to access Quicktime through JS when using an iframe for autoplay


There seems to be only one way to get media to autoplay in iOS versions greater than 4.2, as shown by user bhup here: How can I autoplay media in iOS >= 4.2.1 Mobile Safari?

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

Using this method has one major drawback: I can't find a way to get JS interacting with the Quicktime plugin when using this method.

I have tried many things, but can't find a way to both instantiate the plugin in a way that exposes it to JS and have it autoplay. Any thoughts?


Solution

  • One way:

    In your iFrame element, set onload="parent.someFunction();"

    Then, in someFunction():

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