How to use a while loop for Flow Player in php?

我的梦境 提交于 2019-12-11 14:21:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!