我的Jplayer播放列表的代码工作正常,但我想从我的数据库中填充播放列表。当我使用PHP它不起作用。有人可以告诉我如何做到这一点,而不是非常复杂。
<script>
var myPlaylist = [
{
mp3:'music/hatin.mp3',
title:'Track 1',
artist:'ChaneyBoy, feat. Blu Throwed ',
rating:5,
buy:'#',
price:'17',
duration:'0:38',
cover:'images/coverArt/rv3-small.png'
},
{
mp3:'music/2.mp3',
title:'Track 2',
artist:'BlueFoxMusic',
rating:4,
buy:'#',
price:'17',
duration:'2:51',
cover:'music/2.jpg'
},
{
mp3:'music/hatin.mp3',
title:'Track 3',
artist:'ChaneyBoy, feat. Blu Throwed ',
rating:5,
buy:'#',
price:'17',
duration:'0:38',
cover:'music/1.jpg'
},
{
mp3:'music/2.mp3',
title:'Track 4',
artist:'BlueFoxMusic',
rating:4,
buy:'#',
price:'17',
duration:'2:51',
cover:'music/2.jpg'
},
];
jQuery(document).ready(function ($) {
$('.music-player-list').ttwMusicPlayer(myPlaylist, {
currencySymbol:'$',
buyText:'BUY',
tracksToShow: 10,
autoplay:false,
ratingCallback:function(index, playlistItem, rating){
//some logic to process the rating, perhaps through an ajax call
},
jPlayer:{
swfPath: "http://www.jplayer.org/2.7.0/js/",
supplied: "mp3",
volume: 0.8,
wmode:"window",
solution: "html,flash",
errorAlerts: true,
warningAlerts: true
}
});
});
</script>
上面代码的PHP版本,当我注释掉echo <script>
时,它回应了上面的确切代码;
<?php
include 'includes/config.php';
$get_album_tracks_sql = "SELECT * FROM songs ORDER BY track_number ASC";
$album_tracks_query = mysqli_query($dwn_conn, $get_album_tracks_sql);
echo "<script>";
echo 'var myPlaylist = [';
while($album_tracks_result = mysqli_fetch_array($album_tracks_query)){
echo '{';
echo 'mp3: \'' . $album_tracks_result['file_path'] . '\',';
echo 'title: \'' . $album_tracks_result['track_name'] . '\',';
echo 'artist: \'' . $album_tracks_result['artist_name'] . '\',';
echo 'rating:' . $album_tracks_result['rating'] . ',';
echo 'buy: \' # \' ,';
echo 'price: \'17\' , ';
echo 'duration \'' . $album_tracks_result['duration'] . '\',';
echo 'cover: \'images/coverArt/rv3-small.png\' ';
echo '},';
}//while loop
echo '];';
echo 'jQuery(document).ready(function ($) {';
echo '$(\'.music-player-list\').ttwMusicPlayer(myPlaylist, {';
echo 'currencySymbol:\'$\',';
echo 'buyText:\'BUY\',';
echo 'tracksToShow: 10,';
echo 'autoplay:false,';
echo 'ratingCallback:function(index, playlistItem, rating){';
echo '//some logic to process the rating, perhaps through an ajax call';
echo '},';
echo 'jPlayer:{';
echo 'swfPath: "http://www.jplayer.org/2.7.0/js/",';
echo 'supplied: "mp3",';
echo 'volume: 0.8,';
echo 'wmode:"window",';
echo 'solution: "html,flash",';
echo 'errorAlerts: true,';
echo 'warningAlerts: true';
echo '}';
echo '});';
echo '});';
echo "</script>";
?>
答案 0 :(得分:0)
试试这个::填写$ track数组的其余部分
for image in images:
cur_img =mpimg.imread(image)
...
plt.imshow(cur_img)
sleep(5) #in seconds