<?php
require_once("opentape_common.php");
if ($_GET['download']==true) {
header( 'Location: '.get_base_url() . constant("SONGS_PATH") . 'index.php' );
die();
}
$songlist_struct = scan_songs();
$songlist_struct_original = $songlist_struct;
$prefs_struct = get_opentape_prefs();
$config = array();
$config['playlist'] = array();
// this is where the Projekktor fun begins:
foreach ($songlist_struct as $pos => $row) {
$config['playlist'][] = array(
array(
'src' => get_base_url() . constant("SONGS_PATH") . rawurlencode($row['filename']),
'type' => 'audio/mp3'
),
array(
'src' => str_replace('mp3', 'ogg', get_base_url() . constant("SONGS_PATH") . rawurlencode($row['filename']) ),
'type' => 'audio/ogg'
),
'config' => array(
'title' => ( isset($row['opentape_title']) ) ? $row['opentape_title'] : htmlentities($row['title']),
'poster' => get_base_url() . constant("SONGS_PATH") . rawurlencode('cover.jpg')
)
);
};
// the json / jsonp header
if ($_GET['_jsonp']=='')
{
header("Content-Type: application/json");
}
else {
header("Content-Type: application/javascript");
}
// jsonP callback function and bracket
if ($_GET['_jsonp']!='')
{
echo $_GET['_jsonp'].'(';
}
echo json_encode($config);
// jsonP bracket
if ($_GET['_jsonp']!='')
{
echo $_GET['_jsonp'].');';
}