Last active
September 3, 2021 04:10
-
-
Save Buttars/4dd3e79a4a02a362e0c6eabeb996e398 to your computer and use it in GitHub Desktop.
rick-roll-autoplay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var iframe = document.createElement("iframe"); | |
| iframe.src = "https://www.youtube.com/embed/dQw4w9WgXcQ?enablejsapi=1"; | |
| iframe.id = "player"; | |
| document.body.insertAdjacentElement("afterbegin", iframe); | |
| console.log("running"); | |
| var tag = document.createElement("script"); | |
| tag.id = "iframe-demo"; | |
| tag.src = "https://www.youtube.com/iframe_api"; | |
| var firstScriptTag = document.getElementsByTagName("script")[0]; | |
| firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | |
| function onYouTubeIframeAPIReady() { | |
| var player; | |
| player = new YT.Player("player", { | |
| width: 1280, | |
| height: 720, | |
| videoId: "dQw4w9WgXcQ", | |
| events: { | |
| onReady: onPlayerReady, | |
| }, | |
| }); | |
| } | |
| function onPlayerReady(event) { | |
| event.target.setVolume(100); | |
| event.target.playVideo(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment