Thursday, 15 August 2013

Updating Jplayer playlist items

Updating Jplayer playlist items

I'm working with jplayer, and playlist items. Today the update of the
playlist is done thru a php / mySql database execution. I would like to
update the content of the playlist even if the user stays on the Website
without refreshing. Because the content of my playlist is in a javascript
block I don't know how to update... Please help me... Phil
This is my code and below the original one
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_list",
cssSelectorAncestor: "#jp_container_list"
}, [
<?
$con = mysql_connect('xxxxxxxx', 'xxxxxxxx', 'xxxxxx');
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xxxxxxxxxx");
$resultat_requete1=mysql_query("SELECT title,mp3 FROM podcast ORDER BY ID
DESC LIMIT 0,4");
while($row=mysql_fetch_assoc($resultat_requete1)){
echo json_encode($row).",";
}
mysql_close($con);
?>
], {
swfPath: "player/js",
supplied: "mp3",
cssSelectorAncestor: "#jp_container_list",
wmode: "window",
smoothPlayBar: true,
keyEnabled: true
});
});
//]]>
</script>
this is the original code
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_list",
cssSelectorAncestor: "#jp_container_list"
}, [
{
title:"Cro Magnon Man",
mp3:"http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
oga:"http://www.jplayer.org/audio/ogg/TSP-01-Cro_magnon_man.ogg"
},
{
title:"Your Face",
mp3:"http://www.jplayer.org/audio/mp3/TSP-05-Your_face.mp3",
oga:"http://www.jplayer.org/audio/ogg/TSP-05-Your_face.ogg"
},
{
title:"Cyber Sonnet",
mp3:"http://www.jplayer.org/audio/mp3/TSP-07-Cybersonnet.mp3",
oga:"http://www.jplayer.org/audio/ogg/TSP-07-Cybersonnet.ogg"
},
{
title:"Tempered Song",
mp3:"http://www.jplayer.org/audio/mp3/Miaow-01-Tempered-song.mp3",
oga:"http://www.jplayer.org/audio/ogg/Miaow-01-Tempered-song.ogg"
}
], {
swfPath: "player/js",
supplied: "oga, mp3",
cssSelectorAncestor: "#jp_container_list",
wmode: "window",
smoothPlayBar: true,
keyEnabled: true
});
});
//]]>
</script>

No comments:

Post a Comment