Javascript 使用YouTube嵌入API更新带有视频标题的HTML文本
目前正在努力找出如何在使用YouTube嵌入API播放新视频时更新带有YouTube标题的文本字符串 以下是我要更新的相关HTML段:Javascript 使用YouTube嵌入API更新带有视频标题的HTML文本,javascript,html,youtube,youtube-api,Javascript,Html,Youtube,Youtube Api,目前正在努力找出如何在使用YouTube嵌入API播放新视频时更新带有YouTube标题的文本字符串 以下是我要更新的相关HTML段: <div id="bottom-song-title" class="song-name">No song is playing</div> 我尝试使用innerHTML技术,但无法更新字符串。有什么想法吗 供您查看的当前站点: 谢谢 在这里回答我自己的问题,我就是这样做到的: document.getElementById(“底部歌曲
<div id="bottom-song-title" class="song-name">No song is playing</div>
我尝试使用innerHTML技术,但无法更新字符串。有什么想法吗
供您查看的当前站点:
谢谢 在这里回答我自己的问题,我就是这样做到的:
document.getElementById(“底部歌曲标题”).textContent=event.target.getVideoData().title代码>
希望这对别人有帮助
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.ENDED) {
console.log("END!");
clearTimeout(timeout_setter);
document.getElementById("progress-bar-bottom").style.cssText = "transition: none;";
} else if (event.data == YT.PlayerState.PLAYING) {
console.log("PLAYING");
loopy();
document.getElementById("progress-bar-bottom").style.cssText = "transition: all 1s linear 0s;";
} else {
console.log(event.data);
}
var state = player.getPlayerState();
if (state == 1) {
jQuery('#media-toggle').click(function (event) {
player.pauseVideo();
});
} else {
jQuery('#media-toggle').click(function (event) {
player.playVideo();
});
}
if (state == 1) {
jQuery('#media-toggle-bottom').click(function (event) {
player.pauseVideo();
});
} else {
jQuery('#media-toggle-bottom').click(function (event) {
player.playVideo();
});
}
if (state == 1) {
jQuery('.media-circle').click(function (event) {
player.pauseVideo();
});
} else {
jQuery('.media-circle').click(function (event) {
player.playVideo();
});
}
}