将值插入JWPlayer设置'文件'来自数据库

时间:2015-01-14 22:39:47

标签: php sql arrays jwplayer playlist

另一个JWPlayer问题;是否可以代替对JWPlayer的URL源进行硬编码,使用SQL数据库中的URL数组?

 jwplayer("mainplayer").setup({
        playlist: [{
            file: "https://www.youtube.com/watch?v=uO7kCUjUaUE"
        }],
            primary:"flash",
            autostart: true,
    });

上面的脚本显示了URL实现的硬编码。

<?php

$conn=mysql_connect("localhost", "USER", "PASSWORD")
or die ("Cannot Connect to MYSQL");

mysql_select_db("DATABASENAME", $conn)
or die ("Cannot Connect to the Database");

$id = $_GET['song_id'];
$data = mysql_fetch_array(mysql_query("SELECT * FROM music WHERE id='$id'"));

?>

 jwplayer("mainplayer").setup({
        playlist: [{
            file: "<?php echo $data['URL'] ?>"
        }],
            primary:"flash",
            autostart: true,
    });

JWPlayer是否支持使用以这种方式为单个玩家收集的URL数组并连续播放?谢谢你们

1 个答案:

答案 0 :(得分:3)

变化:

file: "<?php echo $data['URL'] ?>"

要:

file: "<?php echo $data['URL'] ?>",
type: "mp4"

所以完整的事情将是:

jwplayer("mainplayer").setup({
        playlist: [{
            file: "<?php echo $data['URL'] ?>",
            type: "mp4"
        }],
            primary:"flash",
            autostart: true
    });