Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html><head>
- <META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <style>body{margin:0px;}</style>
- </head>
- <body>
- <!-- 1. The <div> tag will contain the <iframe> (youtube video player) -->
- <div id="player"></div>
- <script>
- // 2. This code loads the IFrame Player API code asynchronously.
- var tag = document.createElement('script');
- tag.src = "http://www.youtube.com/player_api";
- var firstScriptTag = document.getElementsByTagName('script')[0];
- firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
- // 3. This function creates an <iframe> (and YouTube player) after the API code downloads.
- var player;
- var vid;
- function setVid(params){
- var obj = JSON.parse(params);
- vid = obj.id
- }
- function onYouTubePlayerAPIReady() {
- player = new YT.Player('player', {
- width: '480',
- height: '280',
- videoId: vid,
- events: {
- 'onReady': onPlayerReady}
- });
- }
- // 4. The API will call this function when the video player is ready.
- // using playVideo() is forbidden in Safari mobile browser as well as StageWebView
- function onPlayerReady(event) {
- event.target.playVideo();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement