예제 #1
0
파일: worker.php 프로젝트: dermidgen/moode
function wrk_mpdconf($kernelver = null, $i2s = null)
{
    // extract mpd.conf from SQLite datastore
    $_tcmods_conf = getTcmodsConf();
    // $mpdcfg = ConfigDB::read('', 'mpdconf');
    $mpdcfg = array_column(ConfigDB::read('', 'mpdconf'), 'value_player', 'param');
    // set mpd.conf file header
    $output = "#########################################\n";
    $output .= "# This file is automatically generated by\n";
    $output .= "# the Player via MPD Configuration page. \n";
    $output .= "#########################################\n";
    $output .= "\n";
    foreach ($mpdcfg as $key => $val) {
        switch ($key) {
            // suppress
            case 'dsd_usb':
                break;
            case 'device':
                $device = $val;
                break;
            case 'mixer_type':
                // get volume mixer control name
                if ('hardware' == ($mixer_type = $mpdcfg['mixer_type'])) {
                    $hwmixer = getMixerName($kernelver, $i2s);
                    break;
                }
                // fallthrough - output mixer_type
            // fallthrough - output mixer_type
            default:
                // don't output disabled audio_output_format
                if ($key !== 'audio_output_format' || $val !== 'disabled') {
                    $output .= $key . " \"" . $val . "\"\n";
                }
        }
    }
    // format audio input / output interfaces
    $output .= <<<EOT
max_connections "20"

decoder {
plugin "ffmpeg"
enabled "yes"
}

input {
plugin "curl"
}

audio_output {
type "alsa"
name "Output"
device "hw:{$device},0"

EOT;
    if (isset($hwmixer)) {
        $output .= "mixer_control \"" . $hwmixer . "\"\n";
        $output .= "mixer_device \"hw:" . $device . "\"\n";
        $output .= "mixer_index \"0\"\n";
    }
    $output .= "dsd_usb \"" . $mpdcfg['dsd_usb'] . "\"\n";
    $output .= "}\n";
    // write mpd.conf file
    file_put_contents("/etc/mpd.conf", $output);
    // store volume mixer type in tcmods.conf
    if ($_tcmods_conf['volume_mixer_type'] != $mixer_type) {
        $_tcmods_conf['volume_mixer_type'] = $mixer_type;
        _updTcmodsConf($_tcmods_conf);
    }
}
예제 #2
0
파일: daemon.php 프로젝트: dermidgen/moode
     }
     // SEARCH URL AND TERMS
     if ($title == "Streaming source") {
         $searchUrl = "<span class=\"playhistory-link\"><i class=\"icon-external-link\"></i></span>";
     } else {
         $searchEngine = "http://www.google.com/search?q=";
         $searchUrl = "<a href=\"" . $searchEngine . $searchStr . "\" class=\"playhistory-link\" target=\"_blank\"><i class=\"icon-external-link-sign\"></i></a>";
     }
     // When song changes, update playback history log
     // TC (Tim Curtis) 2015-07-31: add $title not blank test
     if ($title != '' && $title != $_tcmods_conf['play_history_currentsong']) {
         // Update tcmods.conf file with curentsong
         $_tcmods_conf = getTcmodsConf();
         // re-read to get most current data
         $_tcmods_conf['play_history_currentsong'] = $title;
         $rtn = _updTcmodsConf($_tcmods_conf);
         // Update playback history log
         $history_item = "<li class=\"playhistory-item\"><div>" . date("Y-m-d H:i") . $searchUrl . $title . "</div><span>" . $artist . " - " . $album . "</span></li>";
         //ORIGINAL $history_item = "<li class=\"playhistory-item\"><div>".date("Y-m-d H:i").$searchUrl.$title_log."</div><span>".$artist.", ".$album."</span></li>";
         $rtn = _updatePlayHistory($history_item);
     }
 }
 // getting task requires write access to session
 $task = $args = false;
 Session::wrap(function () use(&$task, &$args) {
     $task = workerPopTask($args);
 }, true);
 // Monitor loop
 if (false !== $task) {
     logWorker("[daemon] Task active: " . $task);
     if (isset($args) & !is_array($args) || count($args)) {
예제 #3
0
파일: tcmods.php 프로젝트: dermidgen/moode
if (isset($_GET['cmd']) && $_GET['cmd'] != '') {
    header('Content-type: application/json');
    switch ($cmd = $_GET['cmd']) {
        case 'getaudiodevdesc':
            $result = ConfigDB::read('cfg_audiodev', $_POST['audiodev']);
            $res = $result[0];
            break;
        case 'getupnpcoverurl':
            $rtn = sysCmd('upexplorer --album-art "' . $_SESSION['upnp_name'] . '"');
            $res = array('coverurl' => $rtn[0]);
            break;
        case 'readtcmconf':
            $res = getTcmodsConf();
            break;
        case 'updatetcmconf':
            $res = _updTcmodsConf($_POST);
            break;
        case 'getmpdstatus':
            $res = _parseStatusResponse(mpdStatus($mpd));
            break;
        case 'readstationfile':
            // misuse mpd function to split lines
            $res = parseMpdKeyedResponse(file_get_contents(MPD_LIB . $_POST['path']), '=');
            break;
        case 'readplayhistory':
            $res = explode("\n", file_get_contents('/var/www/playhistory.log'));
            break;
            // TC (Tim Curtis) 2015-06-26: TESTING ALSA-Direct volume control, requires www-data user in visudo
        // TC (Tim Curtis) 2015-06-26: TESTING ALSA-Direct volume control, requires www-data user in visudo
        case 'sendalsacmd':
            $mixername = getMixerName(getKernelVer($_SESSION['kernelver']), $_SESSION['i2s']);