| 5 | body { margin: 0; width:100%%; height:100%%; background-color:#000; } |
| 6 | html { width:100%%; height:100%%; background-color:#000; } |
| 7 | .embed-container iframe, |
| 8 | .embed-container object, |
| 9 | .embed-container embed { |
| 10 | position: absolute; |
| 11 | top: 0; |
| 12 | left: 0; |
| 13 | width: 100%% !important; |
| 14 | height: 100%% !important; |
| 15 | } |
| 16 | </style> |
| 17 | </head> |
| 18 | <body> |
| 19 | <div class="embed-container"> |
| 20 | <div id="player"></div> |
| 21 | </div> |
| 22 | <script src="https://www.youtube.com/iframe_api"></script> |
| 23 | <script> |
| 24 | var player; |
| 25 | var posted = false; |
| 26 | YT.ready(function() { |
| 27 | player = new YT.Player("player", { |
| 28 | "width": "100%%", |
| 29 | "events": { |
| 30 | "onReady": "onReady", |
| 31 | "onError": "onError", |
| 32 | "onStateChange": "onStateChange", |
| 33 | }, |
| 34 | "videoId": "%1$s", |
| 35 | "height": "100%%", |
| 36 | "playerVars": { |
| 37 | "start": %2$d, |
| 38 | "rel": 1, |
| 39 | "showinfo": 0, |
| 40 | "modestbranding": 0, |
| 41 | "iv_load_policy": 3, |
| 42 | "autohide": 1, |
| 43 | "autoplay": 1, |
| 44 | "cc_load_policy": 1, |
| 45 | "playsinline": 1, |
| 46 | "controls": 0 |
| 47 | } |
| 48 | }); |
| 49 | player.setSize(window.innerWidth, window.innerHeight); |
| 50 | }); |
| 51 | function onError(event) { |
| 52 | if (window.YoutubeProxy !== undefined) { |
| 53 | YoutubeProxy.onPlayerError(event.data); |
| 54 | } |
| 55 | if (!posted) { |
| 56 | if (window.YoutubeProxy !== undefined) { |
| 57 | YoutubeProxy.onPlayerLoaded(); |
| 58 | } |
| 59 | posted = true; |
| 60 | } |
| 61 | } |
| 62 | function onStateChange(event) { |
| 63 | if (event.data == YT.PlayerState.PLAYING && !posted) { |
| 64 | if (window.YoutubeProxy !== undefined) { |
| 65 | YoutubeProxy.onPlayerLoaded(); |
| 66 | } |
| 67 | posted = true; |
| 68 | } |
| 69 | if (window.YoutubeProxy !== undefined) { |
| 70 | YoutubeProxy.onPlayerStateChange(event.data); |
| 71 | } |
| 72 | } |
| 73 | function onReady(event) { |
| 74 | playVideo(); |
| 75 |
| 76 | if (window.YoutubeProxy !== undefined) { |
| 77 | YoutubeProxy.onPlayerNotifyDuration(player.getDuration()); |
| 78 | } |
| 79 | } |
| 80 | function playVideo() { |
| 81 | player.playVideo(); |
| 82 | } |
| 83 | function pauseVideo() { |
| 84 | player.pauseVideo(); |
| 85 | } |
| 86 | function seekTo(time, seekAhead) { |
| 87 | player.seekTo(time, seekAhead); |
| 88 | } |
| 89 | function setPlaybackSpeed(speed) { |
| 90 | player.setPlaybackRate(speed); |
| 91 | } |
| 92 | function pollPosition() { |
| 93 | if (window.YoutubeProxy !== undefined) { |
| 94 | YoutubeProxy.onPlayerNotifyCurrentPosition(player.getCurrentTime()); |
| 95 | YoutubeProxy.onPlayerNotifyBufferedPosition(player.getVideoLoadedFraction()); |
| 96 | } |
| 97 | } |
| 98 | window.onresize = function() { |
| 99 | player.setSize(window.innerWidth, window.innerHeight); |
| 100 | playVideo(); |
| 101 | } |
| 102 | </script> |
| 103 | </body> |
| 104 | </html> |