I am creating a podcast "widget" for a client/friend who hosts a science show.
This code pulls the title and mp3 podcast from an xml feed into jplayer http://www.freeenergymedia.com/shared/PLAYER/player/player.php
reset($titles[1])
is pulling the very last element in the feed while
end($out[1])
is pulling the most recent
I need them to match and both display the most recent
$c = file_get_contents('http://rss.sonibyte.com/rssfeed/56.xml');
preg_match_all('/enclosure url="(.*)" length/', $c, $out, PREG_PATTERN_ORDER);
preg_match_all("|<[title]+>StarTalk:(.*)</[title]+>|U", $c, $titles, PREG_PATTERN_ORDER);
if(sizeof($out[1]) >= 3 && sizeof($titles[1]) >= 3) {
echo '[';
$e = end($out[1]); $b = reset($titles[1]); echo '{ title:"StarTalk:' . $b . '", mp3:"'.$e.'" },';
$e = prev($out[1]); $b = next($titles[1]); echo '{ title:"StarTalk:' . $b . '", mp3:"'.$e.'" },';
$e = prev($out[1]); $b = next($titles[1]); echo '{ title:"StarTalk:' . $b . '", mp3:"'.$e.'" }';
echo ']';
}
the php is inserted into the JPlayer plugin here, to display the mp3 url and title
$(document).ready(function(){
new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1"
}, <?php include('getxmlforplayer.php') ?>, {
swfPath: "js",
supplied: "mp3, oga",
wmode: "window"
});
});