-我想在一个页面上加载许多视频,没什么
特别的 -视频 ID 存储在数据库中 -> $slide['message']
-我可以让它只加载一个视频。其他是空白的
-它在循环中,当 kind == youtube 时,它会尝试将视频放入。
if($slide['kind'] == 'youtube'){
?>
<li>
<div class="info<?php echo $count+1; ?>">
<h1><?php echo $slide['title']; ?></h1>
<div id="ytplayer<?php echo $count+1; ?>" class="youTube-viewer"></div>
<script>
var video = '<?php echo $slide['message']; ?>';
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer<?php echo $count+1; ?>', {
height: '365',
width: '648',
videoId: video,
playerVars: {
'rel': 0,
'enablejsapi': 1,
}
});
}
</script>
<h2><?php echo $slide['name']; ?></h2>
</div>
</li>
<?php
}