Skip to content

Instantly share code, notes, and snippets.

@darkredz
Created April 5, 2013 09:13
Show Gist options
  • Select an option

  • Save darkredz/5317867 to your computer and use it in GitHub Desktop.

Select an option

Save darkredz/5317867 to your computer and use it in GitHub Desktop.
HTML to autoplay youtube iframe api using UIWebView ANE http://darkredz.com/ios-uiwebview-and-videoplayer-native-extension-for-air-mobile/
<!DOCTYPE html>
<html>
<head>
<style>body{margin:0px 0px 0px 0px;}</style>
</head>
<body>
<div id="player"></div>
<script>
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', { width:640, height:480, videoId:'n2_O6PXSDY', events: { 'onReady': onPlayerReady, } });
}
function onPlayerReady(event) {
event.target.playVideo();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment