Пример #1
0
function do_playlist_tracks($pl, $icon)
{
    global $putinplaylistarray, $playlist;
    if ($pl == '[Radio Streams]') {
        $streams = do_mpd_command('listplaylistinfo "' . $pl . '"', true);
        if (is_array($streams) && array_key_exists('file', $streams)) {
            if (!is_array($streams['file'])) {
                $temp = $streams['file'];
                $streams = array();
                $streams['file'][0] = $temp;
            }
            $c = 0;
            foreach ($streams['file'] as $st) {
                add_playlist(rawurlencode($st), htmlentities(substr($st, strrpos($st, '#') + 1, strlen($st))), 'icon-radio-tower', 'clicktrack', true, $c, false);
                $c++;
            }
        }
    } else {
        $putinplaylistarray = true;
        doCollection('listplaylistinfo "' . $pl . '"');
        $c = 0;
        foreach ($playlist as $track) {
            list($class, $link) = $track->get_checked_url();
            add_playlist(rawurlencode($link), htmlentities($track->get_artist_track_title()), 'icon-music', $class, true, $c, false);
            $c++;
        }
    }
}
Пример #2
0
function print_playlists_as_json()
{
    global $putinplaylistarray, $playlist, $prefs;
    $playlists = do_mpd_command("listplaylists", true, true);
    $pls = array();
    $putinplaylistarray = true;
    if (array_key_exists('playlist', $playlists)) {
        foreach ($playlists['playlist'] as $name) {
            $playlist = array();
            $pls[rawurlencode($name)] = array();
            doCollection('listplaylistinfo "' . $name . '"');
            $c = 0;
            $plimage = "";
            $key = md5("Playlist " . htmlentities($name));
            if (file_exists('albumart/asdownloaded/' . $key . ".jpg")) {
                $plimage = 'albumart/asdownloaded/' . $key . ".jpg";
            }
            foreach ($playlist as $track) {
                list($flag, $link) = $track->get_checked_url();
                $pls[rawurlencode($name)][] = array('Uri' => $link, 'Title' => $track->tags['Title'], "Album" => $track->albumobject->name, "Artist" => $track->get_artist_string(), 'albumartist' => $track->albumobject->artist, 'duration' => $track->tags['Time'], 'Image' => $track->albumobject->getImage('small'), 'key' => $track->albumobject->getKey(), 'pos' => $c, 'plimage' => $plimage, 'Type' => $track->tags['type']);
                $c++;
            }
        }
    }
    print json_encode($pls);
}
Пример #3
0
 function login($pwd)
 {
     if (isset($pwd)) {
         $this->password = $pwd;
     }
     if (isset($this->password)) {
         return do_mpd_command("password " . $this->password);
     }
 }
Пример #4
0
function local_media_check($dir)
{
    if ($dir == "Local media") {
        // Mopidy-Local-SQlite contains a virtual tree sorting things by various keys
        // If we scan the whole thing we scan every file about 8 times. This is stoopid.
        // Check to see if 'Local media/Albums' is browseable and use that instead if it is.
        // Using Local media/Folders causes every file to be re-scanned every time we update
        // the collection, which takes f*****g ages and includes all the m3u and pls s***e we don't want
        $r = do_mpd_command('lsinfo "' . $dir . '/Albums"', false, false);
        if ($r === false) {
            return $dir;
        } else {
            return $dir . '/Albums';
        }
    }
    return $dir;
}
Пример #5
0
<?php

chdir('../..');
include "includes/vars.php";
include "includes/functions.php";
include "international.php";
include "player/mpd/connection.php";
$handlers = do_mpd_command('urlhandlers', true);
if (array_key_exists('handler', $handlers)) {
    print json_encode($handlers['handler']);
} else {
    print json_encode(array());
}
close_mpd();
Пример #6
0
<div id="albums">
<?php 
echo "<h2><a name=\"albums\"></a>Albums";
$letters_albums = array();
$tmp = do_mpd_command($connection, "list album" . (array_key_exists("artist", $configuration) ? " \"" . $configuration["artist"] . "\"" : ""), null, true);
if (array_key_exists("Album", $tmp)) {
    if (!is_array($tmp["Album"])) {
        $albums = array($tmp["Album"]);
    } else {
        $albums = $tmp["Album"];
    }
    natcasesort($albums);
    $albums = array_merge(array("Any album" => ""), array_values($albums));
    foreach ($albums as $key => $val) {
        if (!isset($letters_albums[strtoupper(mbFirstChar($val))])) {
            $letters_albums[strtoupper(mbFirstChar($val))] = true;
        }
    }
    $songinfo = null;
    $counte = 0;
    echo " <small>";
    make_index_table($letters_albums, "albums_", false);
    echo "</small></h2>\n";
    echo "<table cellspacing=\"0\">\n";
    foreach ($albums as $key => $val) {
        if ($letters_albums[strtoupper(mbFirstChar($val))] == true) {
            echo "<a name=\"albums_" . strtoupper(mbFirstChar($val)) . "\"></a>";
            $letters_albums[strtoupper(mbFirstChar($val))] = false;
        }
        echo "<tr" . ($counte % 2 != 1 ? " class=\"alt\"" : "") . ">";
        echo "<td>";
Пример #7
0
<?php

$outputdata = array();
@open_mpd_connection();
if ($is_connected) {
    $outputs = do_mpd_command("outputs", true);
    close_mpd($connection);
    foreach ($outputs as $i => $n) {
        if (is_array($n)) {
            foreach ($n as $a => $b) {
                debuglog($i . " - " . $b . ":" . $a, "AUDIO OUTPUT");
                $outputdata[$a][$i] = $b;
            }
        } else {
            debuglog($i . " - " . $n, "AUDIO OUTPUT");
            $outputdata[0][$i] = $n;
        }
    }
}
close_mpd($connection);
function printOutputCheckboxes()
{
    global $outputdata;
    for ($i = 0; $i < count($outputdata); $i++) {
        print '<div class="styledinputs">';
        print '<input type="checkbox" id="outputbutton_' . $i . '"';
        if ($outputdata[$i]['outputenabled'] == 1) {
            print ' checked';
        }
        print '><label for="outputbutton_' . $i . '" onclick="outputswitch(' . $i . ')">' . $outputdata[$i]['outputname'] . '</label>';
        print '</div>';
Пример #8
0
function do_playlists()
{
    global $count;
    global $albums_without_cover;
    global $allfiles;
    $playlists = do_mpd_command("listplaylists", true, true);
    $plfiles = glob('prefs/userplaylists/*');
    foreach ($plfiles as $f) {
        $playlists['playlist'][] = basename($f);
    }
    if (array_key_exists('playlist', $playlists)) {
        print '<div class="cheesegrater" name="savedplaylists">';
        print '<div class="albumsection crackbaby">';
        print '<div class="tleft"><h2>Saved Playlists</h2></div><div class="tright rightpad"><button onclick="getNewAlbumArt(\'#album' . $count . '\')">' . get_int_text("albumart_getthese") . '</button></div>';
        print "</div>\n";
        print '<div id="album' . $count . '" class="fullwidth bigholder">';
        print '<div class="containerbox covercontainer" id="playlists">';
        sort($playlists['playlist'], SORT_STRING);
        $colcount = 0;
        foreach ($playlists['playlist'] as $pl) {
            print '<div class="expand containerbox vertical albumimg closet">';
            print '<div class="albumimg fixed">';
            $class = "";
            $artname = md5("Playlist " . htmlentities($pl));
            $src = "newimages/playlist.svg";
            if (file_exists('albumart/small/' . $artname . '.jpg')) {
                $src = 'albumart/small/' . $artname . '.jpg';
                if (($key = array_search($src, $allfiles)) !== false) {
                    unset($allfiles[$key]);
                }
            } else {
                $class = " notexist";
                $albums_without_cover++;
            }
            $plsearch = preg_replace('/ \\(by .*?\\)$/', '', $pl);
            print '<input type="hidden" value="' . rawurlencode($plsearch) . '" />';
            print '<img class="clickable clickicon clickalbumcover droppable' . $class . '" name="' . $artname . '" height="82px" width="82px" src="' . $src . '" />';
            print '</div>';
            print '<div class="albumimg fixed"><table><tr><td align="center">' . htmlentities($pl) . '</td></tr></table></div>';
            print '</div>';
            $colcount++;
            if ($colcount == 8) {
                print "</div>\n" . '<div class="containerbox covercontainer">';
                $colcount = 0;
            }
            $count++;
        }
        print "</div></div></div>\n";
    }
}
Пример #9
0
<div id="directories">
<?php 
$dirs = array();
$letters_dirs = array();
$ls = do_mpd_command($connection, "lsinfo" . (array_key_exists("directory", $configuration) ? " \"" . $configuration["directory"] . "\"" : ""), null, true);
if (array_key_exists("directory", $ls)) {
    if (is_array($ls["directory"])) {
        foreach ($ls["directory"] as $key => $dir) {
            $dirs[] = $dir;
            if (!isset($letters_dirs[strtoupper(mbFirstChar(basename($dir)))])) {
                $letters_dirs[strtoupper(mbFirstChar(basename($dir)))] = true;
            }
        }
    } else {
        $dirs[] = $ls["directory"];
        $letters_dirs[strtoupper(mbFirstChar(basename($ls["directory"])))] = true;
    }
}
natcasesort($dirs);
$dirs = array_values($dirs);
if (array_key_exists("directory", $configuration) && strlen($configuration["directory"]) > 0 && $configuration["show_dotdot"] == true) {
    $newdir = dirname($configuration["directory"]);
    $dirs = array_merge(array("<<" => $newdir == "." || $newdir == "" || $newdir == "/" ? "" : $newdir), $dirs);
}
if (count($dirs) > 0) {
    $dir = null;
    $counte = 0;
    echo "<h2><a name=\"directories\"></a>Directories  <small>";
    //echo "<h2><a name=\"directories\"></a>Directories  <small>[";
    //	make_link("", "playlist", "add all", $arguments = (array_key_exists("directory", $configuration) ? array("command" => "addall_recursive", "arg" => $configuration["directory"]) : array("command" => "addall_recursive")));
    //	echo "] ";
Пример #10
0
		//echo "<td>".$configuration["delete"]."</td>";
		echo "<td></td>";
		break;
	case "Number":
		echo "<td>#</td>";
		break;
	case "songformat":
		echo "<td>Song</td>";
		break;
	default:
		echo "<td>".$column."</td>";
	}
}
echo "</tr>\n";*/
for ($counte = intval($playlist_start); $counte < $playlist_end; $counte++) {
    $songinfo = do_mpd_command($connection, "playlistinfo " . $counte, null, true);
    $songalt = "";
    foreach ($songinfo as $key => $val) {
        if ($key != "file") {
            $songalt = $songalt . $key . ": " . $val . " ";
        }
    }
    echo "<tr";
    if (array_key_exists("song", $mpd_status) && $counte == $mpd_status["song"]) {
        echo " class=\"hilight\"";
    } else {
        if ($counte % 2 != 1) {
            echo " class=\"alt\"";
        }
    }
    echo ">";
Пример #11
0
 if (is_array($cmd_status) && !array_key_exists('error', $mpd_status) && array_key_exists('error', $cmd_status)) {
     debuglog("Command List Error " . $cmd_status['error'], "POSTCOMMAND", 1);
     $mpd_status = array_merge($mpd_status, $cmd_status);
 }
 //
 // Add current song and replay gain status to mpd_status
 //
 if (array_key_exists('song', $mpd_status) && !array_key_exists('error', $mpd_status)) {
     $songinfo = array();
     $songinfo = do_mpd_command('currentsong', true, false);
     if (is_array($songinfo)) {
         $mpd_status = array_merge($mpd_status, $songinfo);
     }
 }
 $arse = array();
 $arse = do_mpd_command('replay_gain_status', true, false);
 $mpd_status = array_merge($mpd_status, $arse);
 //
 // Clear any player error now we've caught it
 //
 if (array_key_exists('error', $mpd_status)) {
     debuglog("Clearing Player Error " . $mpd_status['error'], "MPD", 7);
     fputs($connection, "clearerror\n");
 }
 //
 // Disable 'single' if we're stopped or paused (single is used for 'Stop After Current Track')
 //
 if ($mpd_status['single'] == 1 && array_key_exists('state', $mpd_status) && ($mpd_status['state'] == "pause" || $mpd_status['state'] == "stop")) {
     debuglog("Cancelling Single Mode", "MPD", 9);
     fputs($connection, 'single "0"' . "\n");
     $mpd_status['single'] = 0;
Пример #12
0
<div id="artists">
<?php 
echo "<h2><a name=\"artists\"></a>Artists";
$letters_artists = array();
$tmp = do_mpd_command($connection, "list artist", null, true);
if (array_key_exists("Artist", $tmp)) {
    if (is_array($tmp["Artist"])) {
        $artists = $tmp["Artist"];
    } else {
        $artists = array($tmp["Artist"]);
    }
    natcasesort($artists);
    $artists = array_merge(array("Any artist" => ""), array_values($artists));
    foreach ($artists as $key => $val) {
        if (!array_key_exists(strtoupper(mbFirstChar($val)), $letters_artists)) {
            $letters_artists[strtoupper(mbFirstChar($val))] = true;
        }
    }
    $songinfo = null;
    $counte = 0;
    echo " <small>";
    make_index_table($letters_artists, "artists_", false);
    echo "</small></h2>\n";
    echo "<table cellspacing=\"0\">\n";
    foreach ($artists as $key => $val) {
        if ($letters_artists[strtoupper(mbFirstChar($val))] == true) {
            echo "<a name=\"artists_" . strtoupper(mbFirstChar($val)) . "\"></a>";
            $letters_artists[strtoupper(mbFirstChar($val))] = false;
        }
        echo "<tr" . ($counte % 2 != 1 ? " class=\"alt\"" : "") . ">";
        echo "<td>";
Пример #13
0
        echo "Playing:";
        break;
}
//echo " <small>[";
//make_link("index.php", "status", "refresh");
//echo "]</small></h2>";
echo "</span><br /><span class=\"playing\">";
if (array_key_exists("command", $_REQUEST) && $_REQUEST["command"]) {
    if ($command_successful !== true && $configuration["error_msg"]) {
        echo "Error on command " . $_REQUEST["command"] . " with arguments: " . $_REQUEST["arg"] . "<br />\n";
    }
}
switch ($mpd_status["state"]) {
    case "play":
    case "pause":
        $songinfo = do_mpd_command($connection, "playlistid " . $mpd_status["songid"], null, true);
        if ($configuration["filenames_only"] == true) {
            echo $songinfo["file"];
        } else {
            echo format_song_title($configuration["song_display_format"], $songinfo, $mpd_status["song"]);
        }
        $elapsed_time = floatval(trim(strtok($mpd_status["time"], ":")));
        $total_time = floatval(trim(strtok("")));
        $remaining_time = $total_time - $elapsed_time;
        echo "<br />\n(";
        if ($configuration["time_elapsed"] == true) {
            make_link("", "status", format_time($elapsed_time), array("time_elapsed" => "false"));
            echo ")/";
        } else {
            echo "-";
            make_link("", "status", format_time($remaining_time), array("time_elapsed" => "true"));
Пример #14
0
        } else {
            $command_successful = false;
        }
    }
    $files = array();
    $letters_files = array();
    if (array_key_exists("searched", $configuration)) {
        $ls = do_mpd_command($connection, $configuration["searched"], null, true);
    } else {
        $ls = do_mpd_command($connection, "lsinfo" . (array_key_exists("directory", $configuration) ? " \"" . $configuration["directory"] . "\"" : ""), null, true);
    }
    if (is_array($ls) && array_key_exists("file", $ls)) {
        if (is_array($ls["file"])) {
            foreach ($ls["file"] as $key => $file) {
                $tmp = do_mpd_command($connection, "listallinfo \"" . $file . "\"", null, true);
                $files[] = $tmp;
                if (!isset($letters_files[strtoupper(mbFirstChar(get_songinfo_first($tmp, isset($configuration["sort"]) ? $configuration["sort"] : array("file"), 0)))])) {
                    $letters_files[strtoupper(mbFirstChar(get_songinfo_first($tmp, isset($configuration["sort"]) ? $configuration["sort"] : array("file"), 0)))] = true;
                }
            }
        } else {
            $tmp = do_mpd_command($connection, "listallinfo \"" . $ls["file"] . "\"", null, true);
            $files[] = $tmp;
            $letters_files[strtoupper(mbFirstChar(get_songinfo_first($tmp, isset($configuration["sort"]) ? $configuration["sort"] : array("file"), 0)))] = 1;
        }
        $files = array_values($files);
        usort($files, "sort_song");
    }
    $mpd_status = do_mpd_command($connection, "status", null, true);
    $is_connected = true;
}
Пример #15
0
if (is_array($r) && array_key_exists('tagtype', $r)) {
    if (in_array('X-AlbumUri', $r['tagtype'])) {
        debuglog("    ....tagtypes test says we're running Mopidy", "INIT", 4);
        $prefs['player_backend'] = "mopidy";
    } else {
        debuglog("    ....tagtypes test says we're running MPD", "INIT", 4);
        $prefs['player_backend'] = "mpd";
    }
} else {
    debuglog("WARNING! No output for 'tagtypes' - probably an old version of Mopidy. Rompr may not function correctly", "INIT", 2);
    $prefs['player_backend'] = "mopidy";
    $oldmopidy = true;
}
if ($prefs['unix_socket'] != '') {
    // If we're connected by a local socket we can read the music directory
    $arse = do_mpd_command('config', true);
    if (array_key_exists('music_directory', $arse)) {
        debuglog("Music Directory Is " . $arse['music_directory'], "INIT", 9);
        $prefs['music_directory'] = $arse['music_directory'];
        if (is_link("prefs/MusicFolders")) {
            system("unlink prefs/MusicFolders");
        }
        system('ln -s "' . $arse['music_directory'] . '" prefs/MusicFolders');
    }
}
close_mpd();
//
// See if we can use the SQL backend
//
// XML backend no longer supported. Force switch to SQLite.
if (array_key_exists('collection_type', $prefs) && $prefs['collection_type'] == "xml") {