Example #1
0
                document.getElementById("pl_info").innerHTML = new_data;
            }

            function breadcrumb(){
                    x_buildBreadcrumb(page,bc_parenttype,bc_parentitem,bc_childtype,bc_childitem,breadcrumb_cb);
            }

            function breadcrumb_cb(new_data){
                //if(new_data!="")
                    document.getElementById("breadcrumb").innerHTML = new_data;
            }

            function play(type,id){
                    document.getElementById('hidden').src = null;
                    document.getElementById("hidden").src = "<?php 
echo stream_url();
?>
mp3act_hidden.php?type="+type+"&id="+id;
            }

            function randAdd(data){
                var type = data.random_type.value;
                if(type == ""){
                    setMsgText("You must choose a random type");
                    return false;
                }
                var num=0;
                num = data.random_count.value;
                var items ='';
                if(type != 'all'){
                    for(var i=0;i<data.random_items.options.length;i++){
function play($type, $id, $quality = 'high')
{
    global $db;
    $tmp = '';
    $query = '';
    if ('pl' == $type) {
        $tmp .= getPlaylistM3u($id, $quality);
    } else {
        $query = 'SELECT ms.song_id, artist_name, ms.name, (ms.length/1000) AS length ' . 'FROM music_songs AS ms ' . 'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id ' . 'WHERE ';
        $sql_id = $db->escape($id);
        switch ($type) {
            case 'song':
                $query .= 'ms.song_id=' . $sql_id;
                break;
            case 'album':
                $query .= 'ms.album_id=' . $sql_id . ' ' . 'ORDER BY ms.track';
                break;
            default:
                return '';
        }
        $sh = $db->query($query);
        if ($sh) {
            while ($row = $sh->fetch_array()) {
                $tmp .= '#EXTINF:' . intval($row['length']) . ',' . utf8_decode($row['artist_name']) . ' - ' . utf8_decode($row['name']) . "\n";
                $tmp .= stream_url() . 'stream?i=' . $row['song_id'] . "\n";
            }
            $sh->finish();
        }
    }
    if ($tmp == '') {
        return '';
    }
    session_cache_limiter('nocache');
    header('Content-Type: audio/mpegurl;');
    header('Content-Disposition: inline; filename="playlist.m3u"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: nocache');
    return "#EXTM3U\n" . $tmp;
}