我需要从 mysql 数据库中获取艺术家轨道的 url,以便通过 jplayer 播放。我用普通的 html 音频控件实现了它,但不能用 jplayer 实现它,因为音频源是在 javascript 中输入的。
以下是我如何使用 html 播放器实现的;
<?php
include ("../database.php");
$result = mysql_query("SELECT * FROM tracks WHERE artistname='$artistname'");
while($row = mysql_fetch_array($result)){
?>
<br><br>
<audio controls="controls" height="50px" width="100px">
<source src=<?php echo $row['trackurl'] ?> type="audio/mp3" />
<embed height="50px" width="100px" src="song.mp3" />
</audio>
<?php } <?
这是 jplayer 的 javascript:
<script type="text/javascript">
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "http://localhost/uploads/dde85d7907e516545ba0860ef1ac23f2.mp3"
});
},
swfPath: "../jplayer",
supplied: "mp3"
});
});
来自 mysql 数据库的 url 需要去它说的地方: mp3: "http://localhost/uploads/dde85d7907e516545ba0860ef1ac23f2.mp3"
最佳答案
您可以使用 AJAX 获取值并将其传递给 jPlayer
关于php - 从 jplayer 的 mysql 数据库获取 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10955943/