Created
November 24, 2020 23:39
-
-
Save camwhite/c57f56b47c5fdd0baf28cdf7d6025f66 to your computer and use it in GitHub Desktop.
This file contains 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
<script setup> | |
import { ref, onMounted } from 'vue' | |
export const player = ref(null) | |
const createPlayer = () => { | |
player.value = new YT.Player('player', { | |
width: '560', | |
height: '349', | |
videoId: 'ScMzIvxBSi4' | |
}) | |
} | |
onMounted(() => { | |
if (!window.YT) { | |
const tag = document.createElement('script') | |
tag.src = 'https://www.youtube.com/player_api' | |
document.body.appendChild(tag) | |
window.onYouTubeIframeAPIReady = function() { | |
createPlayer() | |
} | |
} else { | |
createPlayer() | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment