问题
I have videos that are coming from the server. The first video player works fine but the rest is empty not sure why here is what i have right now.
while($row = mysql_fetch_assoc($query12))
{
echo"<a
href='$urls'
style='display:block;width:520px;height:330px'
id='player'>
</a>
<br/>
<br/>";
}
And this is for the Flow Player
<script>
flowplayer("player", {
src:"flowplayer-3.2.16.swf",
wmode: "opaque" // This allows the HTML to hide the flash content
}, {
clip: {
autoPlay: false
}
});
</script>
回答1:
You can replace the id
for a class
and initialise the players targeting the class name.
Example
Php/Html
while($row = mysql_fetch_assoc($query12))
{
echo"<a
href='$urls'
style='display:block;width:520px;height:330px'
class='player'>
</a>
<br/>
<br/>";
}
JS
<script>
flowplayer("a.player", {
src:"flowplayer-3.2.16.swf",
wmode: "opaque" // This allows the HTML to hide the flash content
}, {
clip: {
autoPlay: false
}
});
</script>
This will now setup multiple players on your page.
回答2:
you might be looking for something like the following because id
's are supposed to be unique
$i = 1;
while($row = mysql_fetch_assoc($query12)){
echo "... id='player-$i' ...";
$i++;
}
<script>
var num = <?php echo $i;?>;
for(i = 1; i <= num; i++){
flowplayer("player-" + i,
{
src:"flowplayer-3.2.16.swf",
wmode: "opaque" // This allows the HTML to hide the flash content
},
{
clip: {
autoPlay: false
}
});
}
</script>
or it looks like you could do:
while($row = mysql_fetch_assoc($query12)){
echo "... class='myplayer' ...";
}
<script>
flowplayer("a.myplayer",
{
src:"flowplayer-3.2.16.swf",
wmode: "opaque" // This allows the HTML to hide the flash content
},
{
clip: {
autoPlay: false
}
});
</script>
来源:https://stackoverflow.com/questions/18414888/how-to-use-a-while-loop-for-flow-player-in-php