<?php
/* URL Query Sting is series */
$series = $_GET['series'];
$files = glob("../$series/*.{mp3,MP3,m4a,M4A}", GLOB_BRACE);
$filename = glob("../$series/*.{mp3,MP3,m4a,M4A}", GLOB_BRACE);
/* JSON data file */
$url = "../$series/data.json"; // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
$info = json_decode($data); // decode the JSON feed
$title = $info[0]->title;
$year = $info[0]->year;
$showinfo = $info[0]->info;
?>
/* Export JSON Key values */
<div> <?php echo($title); ?> </div>
<div> <?php echo($year); ?> </div>
<div> <?php echo ($showinfo); ?> </div>
<?php
$html = "";
for ($i=0; $i<count($files); $i++)
{
$path_parts = pathinfo($filename[$i]);
$num = $files[$i];
$listName = $path_parts['filename'];
$html .= "<div class='playPodcast' audioURL='$num'><span class='pod-title link'> $listName </span></div>";
}
echo($html);
?>
This uses an html query string with php glob to read the only the audio files of an upper level directory creating an audio playlist with information derived from a json data file.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.