我正在使用iframe的YouTube播放器API参考在我的页面上动态制作播放列表。我无法弄清楚如何更改播放列表的标题。它始终保持“无标题播放列表”。请帮忙!
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('youtube-player', {
width: '100%',
loadPlaylist:{
listType:'playlist',
list: youtubeIdsArr,
index:parseInt(0),
suggestedQuality:'small'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
event.target.cuePlaylist(youtubeIdsArr);
}
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
答案 0 :(得分:0)
尝试添加,
transformData(input) {
return input.map(obj => {
for (const prop in obj) {
if (obj.hasOwnProperty(prop) && Array.isArray(obj[prop])) {
for (let i = 0; i < obj[prop].length; i++) {
const name = prop + (i + 1).toString();
obj[name] = obj[prop].flat(1)[i];
}
delete obj[prop];
}
}
return obj;
});
}