关联:
因此,我正在尝试创建一个页面,该页面将生成一个接一个播放的 vimeo 视频播放列表。最终,我将使用 jquery 或其他方式隐藏和显示它们,以便一次只出现一个嵌入式视频 iframe。与此同时,我只是想让 vimeo api 让我控制每个单独的对象。
所以现在想要的结果是让每个设置按钮用相同的 $nummy 值控制每个视频
其中 $nummy 是列表中的顺序
问题是目前只有列表中的最后一个视频响应其自己的按钮集命令。
这是 PHP 的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test The Loop2</title>
<script type="text/javascript" src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
</head>
<body>
<?
//db connect
$con = mysql_connect("d######t","db######104","no#######s");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
//db select
mysql_select_db("db337100104", $con);
$result = mysql_query("SELECT * FROM vim_playlist1");
while($row = mysql_fetch_array($result))
{
$nummy = $row['listnum'] ;
$url = $row['url'] ;
$nexty = $nummy+1 ;
//not an area of php
?>
<iframe class="vimeo" id="play<? echo $nummy ?>" src="http://player.vimeo.com/video/<? echo $row['url'] ?>?api=1&player_id=play<? echo $nummy?>" width="500" height="281" frameborder="0"></iframe>
<br />
<button id="playButton<? echo $nummy ?>">Play</button>
<button id="pauseButton<? echo $nummy ?>">Pause</button>
<button id="unloadButton<? echo $nummy ?>">Unload</button>
<script>
function ready(player_id)
{
$f('play<? echo $nummy?>').addEvent('ready', function()
{
$f('play<? echo $nummy?>').addEvent('finish', onFinish);
});
function onFinish(play<? echo $nummy?>)
{
$f('play<? echo $nexty ?>').api('play');
}
document.getElementById('playButton<? echo $nummy ?>').addEventListener('click', function() {
$f('play<? echo $nummy?>').api('play');
});
document.getElementById('pauseButton<? echo $nummy ?>').addEventListener('click', function() {
$f('play<? echo $nummy?>').api('pause');
});
document.getElementById('unloadButton<? echo $nummy ?>').addEventListener('click', function() {
$f('play<? echo $nummy?>').api('unload');
});
}
window.addEventListener('load', function() {
//Attach the ready event to the iframe
$f(document.getElementById('play<? echo $nummy?>')).addEvent('ready', ready);
});
</script>
<hr />
<?
//end of loop
}
?>
</body>
</html>