Uploading the file locally or using an HTML string will not work due to the same origin policy provided by the web browser.
iframe cannot distribute it postEvent() accesses the main window because Vimeo iframe accesses through the http:// protocol and the local file through the file:// protocol. The Ready event is dispatched through this mechanism.
In this case, you can use the Vimeo API, but to automatically play back the video that you need to know when loading the iframe, but the "finished" event is sent from the iframe to the window via postEvent.
The fact that it uses postEvent is illustrated by the code provided in the Vimeo API Documentation . Froogaloop also uses the same code.
window.addEventListener('message', onMessageReceived, false);
If you run the most basic example of the Vimeo API in an HTML file on your computer, Google Chrome will throw a descriptive message: (Safari does not show this)
An unsafe JavaScript attempt to access a frame with the URL file: ///...index.html from the frame with the URL http://player.vimeo.com... Request for access to the frame has the protocol "http", the frame being accessed has the file protocol. The protocols must match.
This code is simple: ( See this meaning for the full source )
<iframe id="player" width="" height="" src="http://player.vimeo.com/video/62207569?api=1&player_id=player" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> <script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script> <script> var player = $f(document.getElementById('player')); player.addEvent('ready', function() { player.api('play'); }); </script>
The correct solution is to host the HTML page on a remote service that has the same protocol as the Vimeo iframe. In this case, nothing from the http:// address.
If you download the above from http://(insert your host here) , it works instantly in the iOS simulator, Safari and Google chrome.
If you want to do more on the device, you will have to combine the two answers that I gave; Interview the iframe until you find it ready, then tell the player that you are playing.