我想通过存储在Firebase上的一些数据来更新youtube iframe。好的语法是什么?我的参数称为“ concert.youtube”。这是我的代码:
<button onclick="myFunction();return false;">Click me</button>
<div id="video"></div>
<script type="text/javascript">
function myFunction() {
document.getElementById("video").innerHTML = "<div id='player'></div>";
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: "concert.youtube",
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
{
event.target.playVideo();
}
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
//setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
谢谢您的帮助