我正在尝试通过 javascript 更改 Youtube 视频标题颜色和背景,但没有成功。我正在使用本指南http://terrillthompson.com/blog/648和 Youtube 的参考资料https://developers.google.com/youtube/iframe_api_reference
这是整个脚本:(在使用背景之前,我已经在函数 onPlayerReady(event)上尝试了颜色,如下所示)
<script src="http://www.youtube.com/player_api"></script>
<script>
// create youtube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '800',
width: '518',
videoId: 'DHPWtmZ3USs',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
},
playerVars: {
cc_load_policy: 1,
fs: 1,
controls: 0,
showinfo: 0,
autoplay: 0,
rel: 0,
hl: 'pt-br',
color: 'white'
}
});
}
function onPlayerReady(event) {
player.getOptions("captions") || player.getOptions("cc") //detects if captions were ever loaded at one point.
player.setOption("captions", "displaySettings", {"background": "#fff"}); //Works for html5 ignored by AS3
player.setOption("cc", "displaySettings", {"background": "#fff"}); //Works for AS3 ignored by html5
}
// when video ends
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
$('#videoshadow').addClass('on');
}
else if (event.data == YT.PlayerState.PAUSED) {
$('#videoshadow').removeClass('on');
}
else if (event.data == YT.PlayerState.ENDED) {
$('#videoshadow').removeClass('on');
}
}
</script>
和HTML:
<div id="player"></div>
我在网上找不到更多关于此的内容。感谢帮助!