You need to parse your XML file for creating a playlist for jwplayer according to this page. But there is a problem. jwplayer:image
and jwplayer:source
strings cant resolve with simple_xml_load()
for parsing.
I create a code for you. Code needs file_get_contens()
function enabled by the server (because we must change remote XML and resolve the jwplayer:image
problem).
Here is the code;
$source_xml = \'http://www.cpac.ca/tip-podcast/jwplayer.xml\';
$fileContents = file_get_contents( $source_xml );
$fileContents = str_replace( array( \'jwplayer:image\', \'jwplayer:source\', \' file="\', \'" />\' ), array( \'image\', \'file\', \'>\', \'</file>\' ), $fileContents );
$fileContents = trim( str_replace( \'"\', "\'", $fileContents ) );
$simpleXml = simplexml_load_string( $fileContents );
$json = json_encode( array( $simpleXml->channel->item[0], $simpleXml->channel->item[1] ) );
print( $json );
This code resolves your XML file and parses only first two sources for creating playlist items. You can test with your localhost. The result should be like this;
[
{
"title": "April 4, 2019",
"description": "The Prime Minister defends the removal of two former cabinet ministers from the Liberal caucus. Jane Philpott and Jody Wilson-Raybould speak out about the Prime Ministers\' decision. Members of the \\"Daughters of the Vote\\" turn their backs on the Prime Minister, and walk out on Andrew Scheer.",
"image": "http://media.cpac.ca/_app_images/tip_player_poster.png",
"file": "http://www.cpac.ca/tip-podcast/1554372812.mp3"
},
{
"title": "April 3, 2019",
"description": "Jody Wilson-Raybould and Jane Philpott are removed from the Liberal Caucus. Gerald Butts submits text messages, and other evidence, to the justice committee. The Environment Commissioner says Canada isn\'t doing enough to fight climate change. ",
"image": "http://media.cpac.ca/_app_images/tip_player_poster.png",
"file": "http://www.cpac.ca/tip-podcast/1554286033.mp3"
}
]
Best regards