我正在为主持科学节目的客户/朋友创建一个播客“小部件”。
此代码将标题和 mp3 播客从 xml 提要中提取到 jplayer http://www.freeenergymedia.com/shared/PLAYER/player/player.php
reset($titles[1])
正在拉动提要中的最后一个元素,而
end($out[1])
正在拉最新的
我需要它们匹配并且都显示最新的
$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 ']';
}
php在这里插入到JPlayer插件中,显示mp3 url和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"
});
});