MPD+lastfmsubmitd: Clearing my playlist is killing lastmp

Hey folks!
I'm sorry if this topic was already discussed, but i was not able to find it using the board search!
My setup: mpd with ncmpcpp as frontend. Due to some problems with mpdscribble I switched to lastfmsubmitd with lastmp as bridge.
Versions:
* mpd 0.15.12-1
* ncmpcpp 0.5.5-1
* lastfmsubmitd 1.0.6-1
When I clear my current playlist with 'c' in ncmpcpp, i get an error in /var/log/lastfm/lastmp.log and this deamon exits:
2010-09-21 22:09:39,419 lastmp[4035] ERROR: Aborting: Traceback (most recent call last):
File "/usr/bin/lastmp", line 237, in <module>
daemon(cli)
File "/usr/bin/lastmp", line 196, in daemon
mo.observe()
File "/usr/bin/lastmp", line 153, in observe
self.wake()
File "/usr/bin/lastmp", line 78, in wake
song = Song(self.mpd.do.currentsong())
File "/usr/bin/lastmp", line 29, in __init__
self.artist = getattr(sobj, 'artist', '')
File "/usr/lib/python2.6/site-packages/mpdclient2.py", line 270, in __getattr__
return self[attr]
KeyError: 'artist'
As you can imagine: it is quite annoying, if you clear your playlists and every further title is not submitted to last.fm due to this error... Does anyone know how to fix this problem?
Cheers and thanks!
Chris
Last edited by NecroWxrst (2010-09-21 20:20:13)

In the meantime you can edit /usr/bin/lastmp and exchange the first few lines of class Song with the following snippet. Working fine for me and lastmp is surviving playlist clears.
class Song:
def __init__(self, sobj):
self.artist = ''
if hasattr(sobj, 'artist'):
self.artist = getattr(sobj, 'artist')
self.title = ''
if hasattr(sobj, 'title'):
self.title = getattr(sobj, 'title')
self.album = ''
if hasattr(sobj, 'album'):
self.album = getattr(sobj, 'album')
self.time = int(0)
if hasattr(sobj, 'time'):
self.length = int(getattr(sobj, 'time'))
self.file = ''
if hasattr(sobj, 'file'):
self.file = getattr(sobj, 'file')
I already wrote an email to the author with the suggested change but didn't get a reply so far.

Similar Messages

  • I cleared a playlist on my iPhone 4 because I wanted to remove the songs from my phone's storage (I had previously downloaded them) because I wanted to clear storage space. I now want to access the playlist via iCloud and can't. Thoughts?

    I cleared a playlist on my iPhone 4 because I wanted to remove the songs from my phone's storage (I had previously downloaded them) because I wanted to clear storage space. I now want to access the playlist via iCloud and can't. In other words, I want it to sync with the playlist as it exists in iTunes Match. Thoughts?

    Export Photos and Videos from Camera Roll to your computer.
    Empty Camera Roll.
    Make a Folder/Album with all photos and videos you want to have in your iPhone and sync them through iTunes.
    This will free up space in your iPhone and your iCloud.
    The backup of Camera Roll in iCloud is only to restore your iPhone. You can't access them directly.

  • HOW DO YOU CLEAR YOUR PLAYLIST TO CREATE A NEW ONE

    I NEED HELP WHO CA HELP ME WITH THIS ONE I WOULD REALLY APPRECIATE IT. AND ALSO I'M ALSO HAVING PROBLEMS TRYING TO DOWNLOAD NEW MUSIC IN ADDITION TO THE MUSIC I ALREADY HAVE ON MY IPOD. HELP PLEASE!!!!!!!

    What do you mean.... To be honest i dont really understand the question..... but here goes anyway :P
    On iTunes there are two different kinds of playlists. A regular one and a 'smart' one. For a regular (mini pic is a blue sheet with a musical note) playlist if you want to clear it go into it. Click on one song. Press command+a and it will select all the songs in the playlist. Then select delete. Or you could just delete the playlist itself and then create a knew one. If its a 'smart playlist'( purple sheet with a kind of star thing) then you cant manually manage what goes in and out because the playlist operates on certain parameters aka: most played, top rated etc etc.
    On an ipod there are also two kinds of playlists. Regular and 'on the go'. Regular playlists are copied from your itunes to the ipod and you can manage these inn the same way as you would a regular playlist on itunes^^. The other kind of playlist is called on the go. Thee are created by the ipod independantly of a computer. As you browse your library(on the ipod) holding down the select button until the song title flashes adds the selected song to the on the go playlist. To remove songs individually from the playlist, go into the the playlist and select the song you wish to remove and delete it in the same way that you added it in the first place. If you want to clear the playlist simply elect the clear playlist option. These playlist can also be saved. The are then managed in the same way as the regular playlists
    What kind of downloading are you having trouble with. The itunes store downloads directly into itunes. If its from a cd then go into preferences->advanced->importing and there is a drop down box of options of things itunes can do upon inserting a cd. Select import cd and eject. If its from a P2P or torrent system like limewire, utorrent, bittorrent then they download to a folder in your hard drive called downloads. And if one doesn't exist then they create one. Or else they might download to desktop. If you cant find the files then simply search for the name of the downloaded file. To add these to i tunes, if you know the location then you can select import from the file drop doen menu and locate them in the window or else you can just select them all and drag them into the library or else onto the itunes icon in the dock. To put them onto your iPod, you can either sync the ipod with your itunes library. Or else you can select your ipod and sort by the date of the last added file. Then anything added to your library after that date isnt in your library and you can drag files from the librry to the ipod icon in your itunes
    Hope That Helps!!!

  • When my ipod is plugged into my computer music disappears, sometime it tries to upload songs, clears my playlists, and can't locate the songs files. All the same songs are in my Itunes library on my computer. What can i do?

         When I plug my Ipod into my computer it shows all my songs on it as reloading onto the device,
    and sometimes it can't locate the files or they are just gone. All my songs are in my Itunes library
    on my computer, and I do have it in my settings not sync the Ipod with my computer so I can
    manage the content myself. It has happened multiple times.
          I have cleared my Ipod off as well as my computer, and put all the music back on without seeing
    any improvement. And as of today when I tried again it shows some songs on there but with 3 copies
    of the same song trying to upload onto my ipod. And have of my playlist where empty. I am getting
    frustrated and don't know what to do. Help.

    See these previous posts on dotted circles
    https://discussions.apple.com/message/20813679#20813679
    https://discussions.apple.com/message/20792130#20792130
    https://discussions.apple.com/thread/5524609?tstart=0
    https://discussions.apple.com/thread/4643160?start=15&tstart=0

  • Clear the entry for killed/sniped session in v$session

    Dear all,
    In our production database(11.2.0.1.0) running on windows 2008 server many client session showing inactive from last 4-5 hour and I want to kill those session because all sessions are dedicated so for this I created a resource plan set its idle time after certain interval session status is showing killed but it is not removing entries from v$session but our client demand is it must be clear from v$session so for this i was using DOS command taskkill utility to kill particular os process so I want to know what is the smartest way to do this.

    This is known behavior, not an issue.
    In a dedicated server environment when the session is killed and the rollback completes the process goes away so a join between v$session and v$process will fail. The v$session entry also usually goes away rather quickly, though I have seen cases where the v$session entry hung around till the instance was bounced. But normally Oracle will overlay the v$session entry with a new session using the same sid but a different serial# within seconds on a busy system.
    Mark @ http://dbaspot.com/oracle-server/40419-killed-sessions.html
    Metalink doc id 1023442.6 is also something confirming it.
    See also below link and last reply by Mr. Braj Kishore Mahto.
    http://dbaforums.org/oracle/index.php?showtopic=3039
    Regards
    Girish Sharma
    Edited by: Girish Sharma on Nov 21, 2012 5:35 PM
    So, what is best in this regard :
    ALTER SYSTEM DISCONNECT SESSION
    The ALTER SYSTEM DISCONNECT SESSION syntax is an alternative method for killing Oracle sessions. Unlike the KILL SESSION command which asks the session to kill itself, the DISCONNECT SESSION command kills the dedicated server process (or virtual circuit when using Shared Sever), which is equivalent to killing the server process from the operating system. The basic syntax is similar to the KILL SESSION command with the addition of the POST_TRANSACTION clause. The SID and SERIAL# values of the relevant session can be substituted into one of the following statements.
    SQL> ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' POST_TRANSACTION;
    SQL> ALTER SYSTEM DISCONNECT SESSION 'sid,serial#' IMMEDIATE;
    http://www.oracle-base.com/articles/misc/killing-oracle-sessions.php#disconnect_session

  • Mpd removes songs from playlist

    It annoys me that when I go to the next song in my mpd playlist, the previous song gets removed from the playlist. Does anyone know how to get mpd to keep the previous song on the playlist?

    Disable consume mode with $(mpc consume off) or your MPD client's equivalent.

  • Clearing OS SPIDs for KILLED sessions

    Hi All,
    I had killed some sessions in the DB (10.2.0.3) and their status is set to KILLED in v$session.
    I am trying to find the OS PIDs of these sessions to do a "kill -9 " but I could not get them. I am using the below query which is not returning anything as the entry does not exist in v$process:
    select
    p.spid
    from v$session s, v$process p
    where p.addr = s.paddr
    and s.status='KILLED';
    Is there any way to get the OS PIDs of these sessions or to clear the KILLED rows from v$session without bouncing the database.
    Regards,
    Bharath.

    hi,
    once you kill the user then his process and memory will be released..
    post the output of v$session;
    regards,
    Deepak

  • ITunes keeps clearing library + playlists every time I open it.  HELP!

    This problem just arose yesterday, and I still can't figure out why. Every time I close iTunes and reopen it for any reason, my entire library is gone, as are my playlists. I have to manually import all of my songs back in and it's a real pain in the ***, especially since I have to do it AGAIN the next time I open iTunes. At first I thought it was just a problem with the program, so I completely uninstalled it and reinstalled iTunes 9. Same problem. I can re-import my entire library and reconstruct all of my playlists, but the second I close the program and then open it again, it's all gone again. This has to have happened to someone else, and I'm sure the answer is looking me in the face. Can somebody please help me?
    BTW, every time I plug in either my iPhone or iPod nano, it says that it's registered to a different iTunes account, even though the iTunes program I have installed right now has all the right information concerning my accounts.

    Yes, many Vaio owners have seen this exact problem. There is some Sony media management software often preinstalled on Vaio systems that causes a conflict with iTunes saving its library database file. Why it just triggered I can't say, but it is a common issue.
    See this Apple support article:
    http://support.apple.com/kb/TS2715
    and Redkeefy's post in this thread:
    http://discussions.apple.com/message.jspa?messageID=8537277#8537277
    Regards.

  • ITunes remote clears playlist on single click

    I would like to know if anyone else is annoyed by this, or possibly even has a fix. So you have a playlist that a group of people made in iTunes through the iOS remote app, it seems when you single click a song while selecting something it clears the playlist but you just spent all that time creating it. Is it possible to make it edit proof like say you have to enter your four digit code to override the playlist? It doesn't seem like too much to ask, but it is really annoying when you have to go and create a playlist all over again.

    Hey....
    I commented on this in an earlier post to you, but it was burried.
    I think what the problem is, is that you're publishing the playlist, but not the files that the students created.
    The files need to be loaded into iWeb, not just the playlist that you drag over from itunes. Otherwise you're just publishing a hyperlink, or maybe just text.
    The actual files need to be uploaded to a server. Either .Mac using iWeb, or another server. Either way, they have to be up on a server.
    Your itunes playlist points to the files on your local computer, which iWeb can't point to for people on the web to access.
    hope this solves it for you.
    jim

  • PHP MPD Class

    Most mpd.class.php's are old and produce a lot of errors which caused me much frustration in this thread.
    I was wrapping my head around why phpmpreloaded worked and the others never and it's because it uses an updated mpd.class.php. To save others the frustration and hassle I figured I'd post the new class here.
    Enjoy.
    <?php
    * Sven Ginka 03/2010
    * Version mpd.class.php-1.3
    * - take over from Hendrik Stoetter
    * - removed "split()" as this function is marked depracted
    * - added property "xfade" (used by IPodMp, phpMp+)
    * - added property "bitrate" (used by phpMp+)
    * - added define "MPD_SEARCH_FILENAME"
    * - included sorting algorithm "msort"
    * - added function validateFile() for guessing a title if no ID3 data is given
    * Hendrik Stoetter 03/2008
    * - this a lightly modified version of mod.class Version 1.2.
    * - fixed some bugs and added some new functions
    * - Changes:
    * GetDir($url) -> GetDir(url,$sort)
    * var $stats
    * Benjamin Carlisle 05/05/2004
    * mpd.class.php - PHP Object Interface to the MPD Music Player Daemon
    * Version 1.2, Released 05/05/2004
    * Copyright (C) 2003-2004 Benjamin Carlisle ([email protected])
    * http://mpd.24oz.com/ | http://www.musicpd.org/
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    // Create common command definitions for MPD to use
    define("MPD_CMD_STATUS", "status");
    define("MPD_CMD_STATISTICS", "stats");
    define("MPD_CMD_VOLUME", "volume");
    define("MPD_CMD_SETVOL", "setvol");
    define("MPD_CMD_PLAY", "play");
    define("MPD_CMD_STOP", "stop");
    define("MPD_CMD_PAUSE", "pause");
    define("MPD_CMD_NEXT", "next");
    define("MPD_CMD_PREV", "previous");
    define("MPD_CMD_PLLIST", "playlistinfo");
    define("MPD_CMD_PLADD", "add");
    define("MPD_CMD_PLREMOVE", "delete");
    define("MPD_CMD_PLCLEAR", "clear");
    define("MPD_CMD_PLSHUFFLE", "shuffle");
    define("MPD_CMD_PLLOAD", "load");
    define("MPD_CMD_PLSAVE", "save");
    define("MPD_CMD_KILL", "kill");
    define("MPD_CMD_REFRESH", "update");
    define("MPD_CMD_REPEAT", "repeat");
    define("MPD_CMD_LSDIR", "lsinfo");
    define("MPD_CMD_SEARCH", "search");
    define("MPD_CMD_START_BULK", "command_list_begin");
    define("MPD_CMD_END_BULK", "command_list_end");
    define("MPD_CMD_FIND", "find");
    define("MPD_CMD_RANDOM", "random");
    define("MPD_CMD_SEEK", "seek");
    define("MPD_CMD_PLSWAPTRACK", "swap");
    define("MPD_CMD_PLMOVETRACK", "move");
    define("MPD_CMD_PASSWORD", "password");
    define("MPD_CMD_TABLE", "list");
    define("MPD_CMD_PLMOVE", "move" );
    // Predefined MPD Response messages
    define("MPD_RESPONSE_ERR", "ACK");
    define("MPD_RESPONSE_OK", "OK");
    // MPD State Constants
    define("MPD_STATE_PLAYING", "play");
    define("MPD_STATE_STOPPED", "stop");
    define("MPD_STATE_PAUSED", "pause");
    // MPD Searching Constants
    define("MPD_SEARCH_ARTIST", "artist");
    define("MPD_SEARCH_TITLE", "title");
    define("MPD_SEARCH_ALBUM", "album");
    define("MPD_SEARCH_ANY", "any");
    define("MPD_SEARCH_FILENAME","filename");
    // MPD Cache Tables
    define("MPD_TBL_ARTIST","artist");
    define("MPD_TBL_ALBUM","album");
    $mpd_debug = 0;
    function addLog($text){
    global $mpd_debug;
    $style="background-color:lightgrey;border:thin solid grey;margin:5px;padding:5px";
    if ($mpd_debug) echo '<div style="'.$style.'">log:>'.$text.'</div>';
    function addErr($err){
    global $mpd_debug;
    if ($mpd_debug) echo 'error:>'.$err.'<br>';
    class mpd {
    // TCP/Connection variables
    var $host;
    var $port;
    var $password;
    var $mpd_sock = NULL;
    var $connected = FALSE;
    // MPD Status variables
    var $mpd_version = "(unknown)";
    var $state;
    var $current_track_position;
    var $current_track_length;
    var $current_track_id;
    var $volume;
    var $repeat;
    var $random;
    var $uptime;
    var $playtime;
    var $db_last_refreshed;
    var $num_songs_played;
    var $playlist_count;
    var $xfade;
    var $bitrate;
    var $num_artists;
    var $num_albums;
    var $num_songs;
    var $playlist = array();
    var $stats;
    // Misc Other Vars
    var $mpd_class_version = "1.2";
    var $debugging = FALSE; // Set to TRUE to turn extended debugging on.
    var $errStr = ""; // Used for maintaining information about the last error message
    var $command_queue; // The list of commands for bulk command sending
    // =================== BEGIN OBJECT METHODS ================
    /* mpd() : Constructor
    * Builds the MPD object, connects to the server, and refreshes all local object properties.
    function mpd($srv,$port,$pwd = NULL, $debug= FALSE ) {
    $this->host = $srv;
    $this->port = $port;
    $this->password = $pwd;
    $this->debugging = $debug;
    global $mpd_debug;
    $mpd_debug = $debug;
    $resp = $this->Connect();
    if ( is_null($resp) ) {
    addErr( "Could not connect" );
    return;
    } else {
    addLog( "connected");
    list ( $this->mpd_version ) = sscanf($resp, MPD_RESPONSE_OK . " MPD %s\n");
    if ( ! is_null($pwd) ) {
    if ( is_null($this->SendCommand(MPD_CMD_PASSWORD,$pwd)) ) {
    $this->connected = FALSE;
    addErr("bad password");
    return; // bad password or command
    if ( is_null($this->RefreshInfo()) ) { // no read access -- might as well be disconnected!
    $this->connected = FALSE;
    addErr("Password supplied does not have read access");
    return;
    } else {
    if ( is_null($this->RefreshInfo()) ) { // no read access -- might as well be disconnected!
    $this->connected = FALSE;
    addErr("Password required to access server");
    return;
    /* Connect()
    * Connects to the MPD server.
    * NOTE: This is called automatically upon object instantiation; you should not need to call this directly.
    function Connect() {
    addLog( "mpd->Connect() / host: ".$this->host.", port: ".$this->port."\n" );
    $this->mpd_sock = fsockopen($this->host,$this->port,$errNo,$errStr,10);
    if (!$this->mpd_sock) {
    addErr("Socket Error: $errStr ($errNo)");
    return NULL;
    } else {
    $counter=0;
    while(!feof($this->mpd_sock)) {
    $counter++;
    if ($counter > 10){
    addErr("no file end");
    return NULL;
    $response = fgets($this->mpd_sock,1024);
    addLog( $response );
    if (strncmp(MPD_RESPONSE_OK,$response,strlen(MPD_RESPONSE_OK)) == 0) {
    $this->connected = TRUE;
    return $response;
    if (strncmp(MPD_RESPONSE_ERR,$response,strlen(MPD_RESPONSE_ERR)) == 0) {
    // close socket
    fclose($this->mpd_sock);
    addErr("Server responded with: $response");
    return NULL;
    // close socket
    fclose($this->mpd_sock);
    // Generic response
    addErr("Connection not available");
    return NULL;
    /* SendCommand()
    * Sends a generic command to the MPD server. Several command constants are pre-defined for
    * use (see MPD_CMD_* constant definitions above).
    function SendCommand($cmdStr,$arg1 = "",$arg2 = "") {
    addLog("mpd->SendCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2 );
    // Clear out the error String
    $this->errStr = NULL;
    $respStr = "";
    if ( ! $this->connected ) {
    addErr( "mpd->SendCommand() / Error: Not connected");
    } else {
    // Check the command compatibility:
    if ( ! $this->_checkCompatibility($cmdStr) ) {
    return NULL;
    if (strlen($arg1) > 0) $cmdStr .= " \"$arg1\"";
    if (strlen($arg2) > 0) $cmdStr .= " \"$arg2\"";
    fputs($this->mpd_sock,"$cmdStr\n");
    while(!feof($this->mpd_sock)) {
    $response = fgets($this->mpd_sock,1024);
    //addLog($response);
    // An OK signals the end of transmission -- we'll ignore it
    if (strncmp(MPD_RESPONSE_OK,$response,strlen(MPD_RESPONSE_OK)) == 0) {
    break;
    // An ERR signals the end of transmission with an error! Let's grab the single-line message.
    if (strncmp(MPD_RESPONSE_ERR,$response,strlen(MPD_RESPONSE_ERR)) == 0) {
    list ( $junk, $errTmp ) = strtok(MPD_RESPONSE_ERR . " ",$response );
    addErr( strtok($errTmp,"\n") );
    return NULL;
    // Build the response string
    $respStr .= $response;
    addLog("mpd->SendCommand() / response: '".$respStr."'\n");
    return $respStr;
    /* QueueCommand()
    * Queues a generic command for later sending to the MPD server. The CommandQueue can hold
    * as many commands as needed, and are sent all at once, in the order they are queued, using
    * the SendCommandQueue() method. The syntax for queueing commands is identical to SendCommand().
    function QueueCommand($cmdStr,$arg1 = "",$arg2 = "") {
    if ( $this->debugging ) echo "mpd->QueueCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2."\n";
    if ( ! $this->connected ) {
    echo "mpd->QueueCommand() / Error: Not connected\n";
    return NULL;
    } else {
    if ( strlen($this->command_queue) == 0 ) {
    $this->command_queue = MPD_CMD_START_BULK . "\n";
    if (strlen($arg1) > 0) $cmdStr .= " \"$arg1\"";
    if (strlen($arg2) > 0) $cmdStr .= " \"$arg2\"";
    $this->command_queue .= $cmdStr ."\n";
    if ( $this->debugging ) echo "mpd->QueueCommand() / return\n";
    return TRUE;
    /* SendCommandQueue()
    * Sends all commands in the Command Queue to the MPD server. See also QueueCommand().
    function SendCommandQueue() {
    if ( $this->debugging ) echo "mpd->SendCommandQueue()\n";
    if ( ! $this->connected ) {
    echo "mpd->SendCommandQueue() / Error: Not connected\n";
    return NULL;
    } else {
    $this->command_queue .= MPD_CMD_END_BULK . "\n";
    if ( is_null($respStr = $this->SendCommand($this->command_queue)) ) {
    return NULL;
    } else {
    $this->command_queue = NULL;
    if ( $this->debugging ) echo "mpd->SendCommandQueue() / response: '".$respStr."'\n";
    return $respStr;
    /* AdjustVolume()
    * Adjusts the mixer volume on the MPD by <modifier>, which can be a positive (volume increase),
    * or negative (volume decrease) value.
    function AdjustVolume($modifier) {
    if ( $this->debugging ) echo "mpd->AdjustVolume()\n";
    if ( ! is_numeric($modifier) ) {
    $this->errStr = "AdjustVolume() : argument 1 must be a numeric value";
    return NULL;
    $this->RefreshInfo();
    $newVol = $this->volume + $modifier;
    $ret = $this->SetVolume($newVol);
    if ( $this->debugging ) echo "mpd->AdjustVolume() / return\n";
    return $ret;
    /* SetVolume()
    * Sets the mixer volume to <newVol>, which should be between 1 - 100.
    function SetVolume($newVol) {
    if ( $this->debugging ) echo "mpd->SetVolume()\n";
    if ( ! is_numeric($newVol) ) {
    $this->errStr = "SetVolume() : argument 1 must be a numeric value";
    return NULL;
    // Forcibly prevent out of range errors
    if ( $newVol < 0 ) $newVol = 0;
    if ( $newVol > 100 ) $newVol = 100;
    // If we're not compatible with SETVOL, we'll try adjusting using VOLUME
    if ( $this->_checkCompatibility(MPD_CMD_SETVOL) ) {
    if ( ! is_null($ret = $this->SendCommand(MPD_CMD_SETVOL,$newVol))) $this->volume = $newVol;
    } else {
    $this->RefreshInfo(); // Get the latest volume
    if ( is_null($this->volume) ) {
    return NULL;
    } else {
    $modifier = ( $newVol - $this->volume );
    if ( ! is_null($ret = $this->SendCommand(MPD_CMD_VOLUME,$modifier))) $this->volume = $newVol;
    if ( $this->debugging ) echo "mpd->SetVolume() / return\n";
    return $ret;
    /* GetDir()
    * Retrieves a database directory listing of the <dir> directory and places the results into
    * a multidimensional array. If no directory is specified, the directory listing is at the
    * base of the MPD music path.
    function GetDir($dir = "",$sort = "") {
    addLog( "mpd->GetDir()" );
    $resp = $this->SendCommand(MPD_CMD_LSDIR,$dir);
    $listArray = $this->_parseFileListResponse($resp);
    if ($listArray==null){
    return null;
    // we have 3 differnt items: directory, playlist and file
    // we have to sort them individually and separate
    // playlist and directory by name
    // file by $sort
    // 1st: subarrays
    $array_directory = $listArray['directories'];
    $array_playlist = $listArray['playlists'];
    $array_file = $listArray['files'];
    // 2nd: sort them
    natcasesort($array_directory);
    natcasesort($array_playlist);
    usort($array_file,"msort");
    // 3rd: rebuild
    $array_return= array(
    "directories"=> $array_directory,
    "playlists"=> $array_playlist,
    "files"=> $array_file
    foreach ($array_directory as $value) {
    $array_return[]["directory"] = $value;
    foreach ($array_playlist as $value) {
    $array_return[]["playlist"] = $value;
    $array_return = array_merge($array_return,$array_file);
    addLog( "mpd->GetDir() / return ".print_r($array_return,true));
    return $array_return;
    /* GetDirTest() (Unoffical add) -- Returns readable dir contents
    * Retrieves a database directory listing of the <dir> directory and places the results into
    * a multidimensional array. If no directory is specified, the directory listing is at the
    * base of the MPD music path.
    function GetDirTest($dir = "") {
    if ( $this->debugging ) echo "mpd->GetDir()\n";
    $resp = $this->SendCommand(MPD_CMD_LSDIR,$dir);
    #$dirlist = $this->_parseFileListResponse($resp);
    $dirlist = $this->_parseFileListResponseHumanReadable($resp);
    if ( $this->debugging ) echo "mpd->GetDir() / return ".print_r($dirlist)."\n";
    return $dirlist;
    /* PLAdd()
    * Adds each track listed in a single-dimensional <trackArray>, which contains filenames
    * of tracks to add, to the end of the playlist. This is used to add many, many tracks to
    * the playlist in one swoop.
    function PLAddBulk($trackArray) {
    if ( $this->debugging ) echo "mpd->PLAddBulk()\n";
    $num_files = count($trackArray);
    for ( $i = 0; $i < $num_files; $i++ ) {
    $this->QueueCommand(MPD_CMD_PLADD,$trackArray[$i]);
    $resp = $this->SendCommandQueue();
    $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLAddBulk() / return\n";
    return $resp;
    /* PLAdd()
    * Adds the file <file> to the end of the playlist. <file> must be a track in the MPD database.
    function PLAdd($fileName) {
    if ( $this->debugging ) echo "mpd->PLAdd()\n";
    if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLADD,$fileName))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLAdd() / return\n";
    return $resp;
    /* PLMoveTrack()
    * Moves track number <origPos> to position <newPos> in the playlist. This is used to reorder
    * the songs in the playlist.
    function PLMoveTrack($origPos, $newPos) {
    if ( $this->debugging ) echo "mpd->PLMoveTrack()\n";
    if ( ! is_numeric($origPos) ) {
    $this->errStr = "PLMoveTrack(): argument 1 must be numeric";
    return NULL;
    if ( $origPos < 0 or $origPos > $this->playlist_count ) {
    $this->errStr = "PLMoveTrack(): argument 1 out of range";
    return NULL;
    if ( $newPos < 0 ) $newPos = 0;
    if ( $newPos > $this->playlist_count ) $newPos = $this->playlist_count;
    if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLMOVETRACK,$origPos,$newPos))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLMoveTrack() / return\n";
    return $resp;
    /* PLShuffle()
    * Randomly reorders the songs in the playlist.
    function PLShuffle() {
    if ( $this->debugging ) echo "mpd->PLShuffle()\n";
    if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLSHUFFLE))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLShuffle() / return\n";
    return $resp;
    /* PLLoad()
    * Retrieves the playlist from <file>.m3u and loads it into the current playlist.
    function PLLoad($file) {
    if ( $this->debugging ) echo "mpd->PLLoad()\n";
    if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLLOAD,$file))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLLoad() / return\n";
    return $resp;
    /* PLSave()
    * Saves the playlist to <file>.m3u for later retrieval. The file is saved in the MPD playlist
    * directory.
    function PLSave($file) {
    if ( $this->debugging ) echo "mpd->PLSave()\n";
    $resp = $this->SendCommand(MPD_CMD_PLSAVE,$file);
    if ( $this->debugging ) echo "mpd->PLSave() / return\n";
    return $resp;
    /* PLClear()
    * Empties the playlist.
    function PLClear() {
    if ( $this->debugging ) echo "mpd->PLClear()\n";
    if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLCLEAR))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLClear() / return\n";
    return $resp;
    /* PLRemove()
    * Removes track <id> from the playlist.
    function PLRemove($id) {
    if ( $this->debugging ) echo "mpd->PLRemove()\n";
    if ( ! is_numeric($id) ) {
    $this->errStr = "PLRemove() : argument 1 must be a numeric value";
    return NULL;
    if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLREMOVE,$id))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->PLRemove() / return\n";
    return $resp;
    /* SetRepeat()
    * Enables 'loop' mode -- tells MPD continually loop the playlist. The <repVal> parameter
    * is either 1 (on) or 0 (off).
    function SetRepeat($repVal) {
    if ( $this->debugging ) echo "mpd->SetRepeat()\n";
    $rpt = $this->SendCommand(MPD_CMD_REPEAT,$repVal);
    $this->repeat = $repVal;
    if ( $this->debugging ) echo "mpd->SetRepeat() / return\n";
    return $rpt;
    /* SetRandom()
    * Enables 'randomize' mode -- tells MPD to play songs in the playlist in random order. The
    * <rndVal> parameter is either 1 (on) or 0 (off).
    function SetRandom($rndVal) {
    if ( $this->debugging ) echo "mpd->SetRandom()\n";
    $resp = $this->SendCommand(MPD_CMD_RANDOM,$rndVal);
    $this->random = $rndVal;
    if ( $this->debugging ) echo "mpd->SetRandom() / return\n";
    return $resp;
    /* Shutdown()
    * Shuts down the MPD server (aka sends the KILL command). This closes the current connection,
    * and prevents future communication with the server.
    function Shutdown() {
    if ( $this->debugging ) echo "mpd->Shutdown()\n";
    $resp = $this->SendCommand(MPD_CMD_SHUTDOWN);
    $this->connected = FALSE;
    unset($this->mpd_version);
    unset($this->errStr);
    unset($this->mpd_sock);
    if ( $this->debugging ) echo "mpd->Shutdown() / return\n";
    return $resp;
    /* DBRefresh()
    * Tells MPD to rescan the music directory for new tracks, and to refresh the Database. Tracks
    * cannot be played unless they are in the MPD database.
    function DBRefresh() {
    if ( $this->debugging ) echo "mpd->DBRefresh()\n";
    $resp = $this->SendCommand(MPD_CMD_REFRESH);
    // Update local variables
    $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->DBRefresh() / return\n";
    return $resp;
    /* Play()
    * Begins playing the songs in the MPD playlist.
    function Play() {
    if ( $this->debugging ) echo "mpd->Play()\n";
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_PLAY) )) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->Play() / return\n";
    return $rpt;
    /* Stop()
    * Stops playing the MPD.
    function Stop() {
    if ( $this->debugging ) echo "mpd->Stop()\n";
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_STOP) )) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->Stop() / return\n";
    return $rpt;
    /* Pause()
    * Toggles pausing on the MPD. Calling it once will pause the player, calling it again
    * will unpause.
    function Pause() {
    if ( $this->debugging ) echo "mpd->Pause()\n";
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_PAUSE) )) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->Pause() / return\n";
    return $rpt;
    /* SeekTo()
    * Skips directly to the <idx> song in the MPD playlist.
    function SkipTo($idx) {
    if ( $this->debugging ) echo "mpd->SkipTo()\n";
    if ( ! is_numeric($idx) ) {
    $this->errStr = "SkipTo() : argument 1 must be a numeric value";
    return NULL;
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_PLAY,$idx))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->SkipTo() / return\n";
    return $idx;
    /* SeekTo()
    * Skips directly to a given position within a track in the MPD playlist. The <pos> argument,
    * given in seconds, is the track position to locate. The <track> argument, if supplied is
    * the track number in the playlist. If <track> is not specified, the current track is assumed.
    function SeekTo($pos, $track = -1) {
    if ( $this->debugging ) echo "mpd->SeekTo()\n";
    if ( ! is_numeric($pos) ) {
    $this->errStr = "SeekTo() : argument 1 must be a numeric value";
    return NULL;
    if ( ! is_numeric($track) ) {
    $this->errStr = "SeekTo() : argument 2 must be a numeric value";
    return NULL;
    if ( $track == -1 ) {
    $track = $this->current_track_id;
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_SEEK,$track,$pos))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->SeekTo() / return\n";
    return $pos;
    /* Next()
    * Skips to the next song in the MPD playlist. If not playing, returns an error.
    function Next() {
    if ( $this->debugging ) echo "mpd->Next()\n";
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_NEXT))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->Next() / return\n";
    return $rpt;
    /* Previous()
    * Skips to the previous song in the MPD playlist. If not playing, returns an error.
    function Previous() {
    if ( $this->debugging ) echo "mpd->Previous()\n";
    if ( ! is_null($rpt = $this->SendCommand(MPD_CMD_PREV))) $this->RefreshInfo();
    if ( $this->debugging ) echo "mpd->Previous() / return\n";
    return $rpt;
    /* Search()
    * Searches the MPD database. The search <type> should be one of the following:
    * MPD_SEARCH_ARTIST, MPD_SEARCH_TITLE, MPD_SEARCH_ALBUM
    * The search <string> is a case-insensitive locator string. Anything that contains
    * <string> will be returned in the results.
    function Search($type,$string) {
    addLog("mpd->Search()");
    if ( $type != MPD_SEARCH_ARTIST and
    $type != MPD_SEARCH_ALBUM and
    $type != MPD_SEARCH_ANY and
    $type != MPD_SEARCH_TITLE ) {
    addErr( "mpd->Search(): invalid search type" );
    return NULL;
    } else {
    if ( is_null($resp = $this->SendCommand(MPD_CMD_SEARCH,$type,$string))) return NULL;
    $searchlist = $this->_parseFileListResponse($resp);
    addLog( "mpd->Search() / return ".print_r($searchlist,true) );
    return $searchlist;
    /* Find()
    * Find() looks for exact matches in the MPD database. The find <type> should be one of
    * the following:
    * MPD_SEARCH_ARTIST, MPD_SEARCH_TITLE, MPD_SEARCH_ALBUM
    * The find <string> is a case-insensitive locator string. Anything that exactly matches
    * <string> will be returned in the results.
    function Find($type,$string) {
    if ( $this->debugging ) echo "mpd->Find()\n";
    if ( $type != MPD_SEARCH_ARTIST and
    $type != MPD_SEARCH_ALBUM and
    $type != MPD_SEARCH_TITLE ) {
    $this->errStr = "mpd->Find(): invalid find type";
    return NULL;
    } else {
    if ( is_null($resp = $this->SendCommand(MPD_CMD_FIND,$type,$string))) return NULL;
    $searchlist = $this->_parseFileListResponse($resp);
    if ( $this->debugging ) echo "mpd->Find() / return ".print_r($searchlist)."\n";
    return $searchlist;
    /* Disconnect()
    * Closes the connection to the MPD server.
    function Disconnect() {
    if ( $this->debugging ) echo "mpd->Disconnect()\n";
    fclose($this->mpd_sock);
    $this->connected = FALSE;
    unset($this->mpd_version);
    unset($this->errStr);
    unset($this->mpd_sock);
    /* GetArtists()
    * Returns the list of artists in the database in an associative array.
    function GetArtists() {
    if ( $this->debugging ) echo "mpd->GetArtists()\n";
    if ( is_null($resp = $this->SendCommand(MPD_CMD_TABLE, MPD_TBL_ARTIST))) return NULL;
    $arArray = array();
    $arLine = strtok($resp,"\n");
    $arName = "";
    $arCounter = -1;
    while ( $arLine ) {
    list ( $element, $value ) = explode(": ",$arLine);
    if ( $element == "Artist" ) {
    $arCounter++;
    $arName = $value;
    $arArray[$arCounter] = $arName;
    $arLine = strtok("\n");
    if ( $this->debugging ) echo "mpd->GetArtists()\n";
    return $arArray;
    /* GetAlbums()
    * Returns the list of albums in the database in an associative array. Optional parameter
    * is an artist Name which will list all albums by a particular artist.
    function GetAlbums( $ar = NULL) {
    if ( $this->debugging ) echo "mpd->GetAlbums()\n";
    if ( is_null($resp = $this->SendCommand(MPD_CMD_TABLE, MPD_TBL_ALBUM, $ar ))) return NULL;
    $alArray = array();
    $alLine = strtok($resp,"\n");
    $alName = "";
    $alCounter = -1;
    while ( $alLine ) {
    list ( $element, $value ) = explode(": ",$alLine);
    if ( $element == "Album" ) {
    $alCounter++;
    $alName = $value;
    $alArray[$alCounter] = $alName;
    $alLine = strtok("\n");
    if ( $this->debugging ) echo "mpd->GetAlbums()\n";
    return $alArray;
    //***************************** INTERNAL FUNCTIONS ******************************//
    /* _computeVersionValue()
    * Computes a compatibility value from a version string
    private function _computeVersionValue($verStr) {
    list ($ver_maj, $ver_min, $ver_rel ) = explode(".",$verStr);
    return ( 100 * $ver_maj ) + ( 10 * $ver_min ) + ( $ver_rel );
    /* _checkCompatibility()
    * Check MPD command compatibility against our internal table. If there is no version
    * listed in the table, allow it by default.
    private function _checkCompatibility($cmd) {
    // Check minimum compatibility
    if (isset($this->COMPATIBILITY_MIN_TBL[$cmd])){
    $req_ver_low = $this->COMPATIBILITY_MIN_TBL[$cmd];
    } else {
    $req_ver_low = "0.9.1";
    // check max compatibility
    if (isset($this->COMPATIBILITY_MAX_TBL[$cmd])){
    $req_ver_hi = $this->COMPATIBILITY_MAX_TBL[$cmd];
    } else {
    $req_ver_hi = "0.20.0";
    $mpd_ver = $this->_computeVersionValue($this->mpd_version);
    if ( $req_ver_low ) {
    $req_ver = $this->_computeVersionValue($req_ver_low);
    if ( $mpd_ver < $req_ver ) {
    addErr("Command '$cmd' is not compatible with this version of MPD, version ".$req_ver_low." required");
    return FALSE;
    // Check maximum compatibility -- this will check for deprecations
    if ( $req_ver_hi ) {
    $req_ver = $this->_computeVersionValue($req_ver_hi);
    if ( $mpd_ver > $req_ver ) {
    addErr("Command '$cmd' has been deprecated in this version of MPD.");
    return FALSE;
    return TRUE;
    * checks the file entry and complete it if necesarry
    * checked fields are 'Artist', 'Genre' and 'Title'
    private function _validateFile( $fileItem ){
    $filename = $fileItem['file'];
    if (!isset($fileItem['Artist'])){ $fileItem['Artist']=null; }
    if (!isset($fileItem['Genre'])){ $fileItem['Genre']=null; }
    // special conversion for streams
    if (stripos($filename, 'http' )!==false){
    if (!isset($fileItem['Title'])) $title = ''; else $title=$fileItem['Title'];
    if (!isset($fileItem['Name'])) $name = ''; else $name=$fileItem['Name'];
    if (!isset($fileItem['Artist'])) $artist = ''; else $artist=$fileItem['Artist'];
    if (strlen($title.$name.$artist)==0){
    $fileItem['Title'] = $filename;
    } else {
    $fileItem['Title'] = 'stream://'.$title.' '.$name.' '.$artist;
    if (!isset($fileItem['Title'])){
    $file_parts = explode('/', $filename);
    $fileItem['Title'] = $filename;
    return $fileItem;
    * take the response of mpd and split it up into
    * items of types 'file', 'directory' and 'playlist'
    private function _extractItems( $resp ){
    if ( $resp == null ) {
    addLog('empty file list');
    return NULL;
    // strip unwanted chars
    $resp = trim($resp);
    // split up into lines
    $lineList = explode("\n", $resp );
    $array = array();
    $item=null;
    foreach ($lineList as $line ){
    list ( $element, $value ) = explode(": ",$line);
    // if one of the key words come up, store the item
    if (($element == "directory") or ($element=="playlist") or ($element=="file")){
    if ($item){
    $array[] = $item;
    $item = array();
    $item[$element] = $value;
    // check if there is a last item to store
    if (sizeof($item)>0){
    $array[] = $item;
    return $array;
    /* _parseFileListResponse()
    * Builds a multidimensional array with MPD response lists.
    * NOTE: This function is used internally within the class. It should not be used.
    private function _parseFileListResponse($resp) {
    $valuesArray = $this->_extractItems( $resp );
    if ($valuesArray == null ){
    return null;
    //1. create empty arrays
    $directoriesArray = array();
    $filesArray = array();
    $playlistsArray = array();
    //2. sort the items
    foreach ( $valuesArray as $item ) {
    if (isset($item['file'])){
    $filesArray[] = $this->_validateFile($item);
    } else if (isset($item['directory'])){
    $directoriesArray[] = $item['directory'];
    } else if (isset($item['playlist'])){
    $playlistsArray[] = $item['playlist'];
    } else {
    addErr('should not enter this');
    //3. create a combined list of items
    $returnArray = array(
    "directories"=>$directoriesArray,
    "playlists"=>$playlistsArray,
    "files"=>$filesArray
    addLog( print_r($valuesArray,true) );
    return $returnArray;
    /* RefreshInfo()
    * Updates all class properties with the values from the MPD server.
    * NOTE: This function is automatically called upon Connect() as of v1.1.
    function RefreshInfo() {
    // Get the Server Statistics
    $statStr = $this->SendCommand(MPD_CMD_STATISTICS);
    if ( !$statStr ) {
    return NULL;
    } else {
    $stats = array();
    $statStr=trim($statStr);
    $statLine = explode( "\n", $statStr );
    foreach ( $statLine as $line ) {
    list ( $element, $value ) = explode(": ",$line);
    $stats[$element] = $value;
    // Get the Server Status
    $statusStr = $this->SendCommand(MPD_CMD_STATUS);
    if ( ! $statusStr ) {
    return NULL;
    } else {
    $status = array();
    $statusStr=trim($statusStr);
    $statusLine = explode("\n", $statusStr );
    foreach ( $statusLine as $line ) {
    list ( $element, $value ) = explode(": ",$line);
    $status[$element] = $value;
    // Get the Playlist
    $plStr = $this->SendCommand(MPD_CMD_PLLIST);
    $array = $this->_parseFileListResponse($plStr);
    $playlist = $array['files'];
    $this->playlist_count = count($playlist);
    $this->playlist = array();
    if (sizeof($playlist)>0){
    foreach ($playlist as $item ){
    $this->playlist[$item['Pos']]=$item;
    // Set Misc Other Variables
    $this->state = $status['state'];
    if ( ($this->state == MPD_STATE_PLAYING) || ($this->state == MPD_STATE_PAUSED) ) {
    $this->current_track_id = $status['song'];
    list ($this->current_track_position, $this->current_track_length ) = explode(":",$status['time']);
    } else {
    $this->current_track_id = -1;
    $this->current_track_position = -1;
    $this->current_track_length = -1;
    $this->repeat = $status['repeat'];
    $this->random = $status['random'];
    $this->db_last_refreshed = $stats['db_update'];
    $this->volume = $status['volume'];
    $this->uptime = $stats['uptime'];
    $this->playtime = $stats['playtime'];
    $this->num_songs_played = $stats['songs'];
    $this->num_artists = $stats['artists'];
    $this->num_songs = $stats['songs'];
    $this->num_albums = $stats['albums'];
    $this->xfade = $status['xfade'];
    if(isset($status['bitrate'])) $this->bitrate = $status['bitrate'];
    else $this->bitrate = FALSE;
    return TRUE;
    /* ------------------ DEPRECATED METHODS -------------------*/
    /* GetStatistics()
    * Retrieves the 'statistics' variables from the server and tosses them into an array.
    * NOTE: This function really should not be used. Instead, use $this->[variable]. The function
    * will most likely be deprecated in future releases.
    function GetStatistics() {
    if ( $this->debugging ) echo "mpd->GetStatistics()\n";
    $stats = $this->SendCommand(MPD_CMD_STATISTICS);
    if ( !$stats ) {
    return NULL;
    } else {
    $statsArray = array();
    $statsLine = strtok($stats,"\n");
    while ( $statsLine ) {
    list ( $element, $value ) = explode(": ",$statsLine);
    $statsArray[$element] = $value;
    $statsLine = strtok("\n");
    if ( $this->debugging ) echo "mpd->GetStatistics() / return: " . print_r($statsArray) ."\n";
    return $statsArray;
    /* GetStatus()
    * Retrieves the 'status' variables from the server and tosses them into an array.
    * NOTE: This function really should not be used. Instead, use $this->[variable]. The function
    * will most likely be deprecated in future releases.
    function GetStatus() {
    if ( $this->debugging ) echo "mpd->GetStatus()\n";
    $status = $this->SendCommand(MPD_CMD_STATUS);
    if ( ! $status ) {
    return NULL;
    } else {
    $statusArray = array();
    $statusLine = strtok($status,"\n");
    while ( $statusLine ) {
    list ( $element, $value ) = explode(": ",$statusLine);
    $statusArray[$element] = $value;
    $statusLine = strtok("\n");
    if ( $this->debugging ) echo "mpd->GetStatus() / return: " . print_r($statusArray) ."\n";
    return $statusArray;
    /* GetVolume()
    * Retrieves the mixer volume from the server.
    * NOTE: This function really should not be used. Instead, use $this->volume. The function
    * will most likely be deprecated in future releases.
    function GetVolume() {
    if ( $this->debugging ) echo "mpd->GetVolume()\n";
    $volLine = $this->SendCommand(MPD_CMD_STATUS);
    if ( ! $volLine ) {
    return NULL;
    } else {
    list ($vol) = sscanf($volLine,"volume: %d");
    if ( $this->debugging ) echo "mpd->GetVolume() / return: $vol\n";
    return $vol;
    /* GetPlaylist()
    * Retrieves the playlist from the server and tosses it into a multidimensional array.
    * NOTE: This function really should not be used. Instead, use $this->playlist. The function
    * will most likely be deprecated in future releases.
    function GetPlaylist() {
    if ( $this->debugging ) echo "mpd->GetPlaylist()\n";
    $resp = $this->SendCommand(MPD_CMD_PLLIST);
    $playlist = $this->_parseFileListResponse($resp);
    if ( $this->debugging ) echo "mpd->GetPlaylist() / return ".print_r($playlist)."\n";
    return $playlist;
    /* ----------------- Command compatibility tables --------------------- */
    var $COMPATIBILITY_MIN_TBL = array(
    MPD_CMD_SEEK => "0.9.1" ,
    MPD_CMD_PLMOVE => "0.9.1" ,
    MPD_CMD_RANDOM => "0.9.1" ,
    MPD_CMD_PLSWAPTRACK => "0.9.1" ,
    MPD_CMD_PLMOVETRACK => "0.9.1" ,
    MPD_CMD_PASSWORD => "0.10.0" ,
    MPD_CMD_SETVOL => "0.10.0"
    var $COMPATIBILITY_MAX_TBL = array(
    MPD_CMD_VOLUME => "0.10.0"
    } // ---------------------------- end of class ------------------------------
    function msort($a,$b) {
    global $sort_array,$filenames_only;
    $i=0;
    $ret = 0;
    while($filenames_only!="yes" && $i<4 && $ret==0) {
    if(!isset($a[$sort_array[$i]])) {
    if(isset($b[$sort_array[$i]])) {
    $ret = -1;
    else if(!isset($b[$sort_array[$i]])) {
    $ret = 1;
    else if(strcmp($sort_array[$i],"Track")==0) {
    $ret = strnatcmp($a[$sort_array[$i]],$b[$sort_array[$i]]);
    else {
    $ret = strcasecmp($a[$sort_array[$i]],$b[$sort_array[$i]]);
    $i++;
    if($ret==0)
    $ret = strcasecmp($a["file"],$b["file"]);
    return $ret;
    function picksort($pick) {
    global $sort_array;
    if(0==strcmp($pick,$sort_array[0])) {
    return "$sort_array[0],$sort_array[1],$sort_array[2],$sort_array[3]";
    else if(0==strcmp($pick,$sort_array[1])) {
    return "$pick,$sort_array[0],$sort_array[2],$sort_array[3]";
    else if(0==strcmp($pick,$sort_array[2])) {
    return "$pick,$sort_array[0],$sort_array[1],$sort_array[3]";
    else if(0==strcmp($pick,$sort_array[3])) {
    return "$pick,$sort_array[0],$sort_array[1],$sort_array[2]";
    ?>

    BaconPie wrote:I used it to make a web based remote control for my phone. Glad it was of some help.
    regarding the phone client, ... there is one in the phpMpReloaded project called IPodMp :-)
    http://phpmpreloaded.sourceforge.net/sc … IPodMp.png
    cheers
    -tswaehn

  • [SOLVED] mpd: Failed to stat /var/lib/mpd/music: Permission denied

    I've set up mpd according to the wiki.
    /etc/mpd.conf:
    music_directory "/var/lib/mpd/music"
    playlist_directory "/var/lib/mpd/playlists"
    db_file "/var/lib/mpd/mpd.db"
    log_file "/var/log/mpd/mpd.log"
    pid_file "/run/mpd/mpd.pid
    state_file "/var/lib/mpd/mpdstate"
    user "mpd"
    audio_output {
    type "pulse"
    name "My Pulse Output"
    # server "remote_server" # optional
    # sink "remote_server_sink" # optional
    /var/lib/mpd/music is a symlink to /home/dennis/Musik/mpd/. I've given the mpd user recursive ownership to both /var/lib/mpd/ and /home/dennis/Musik/mpd/.
    When I try to update the database (I've tried both mpc and Sonata), the log says
    Failed to stat /var/lib/mpd/music: Permission denied
    What permission am I missing?
    SOLUTION:
    I used the script config instead and it worked flawlessly.
    Last edited by snufkin (2013-01-03 00:18:44)

    I returned this:
    ene 17 21:00:55 ddich systemd[1]: Starting Music Player Daemon...
    ene 17 21:00:55 ddich systemd[1]: Started Music Player Daemon.
    ene 17 21:00:55 ddich mpd[14061]: output: No 'audio_output' defined in config file
    ene 17 21:00:55 ddich mpd[14061]: output: Attempt to detect audio output device
    ene 17 21:00:55 ddich mpd[14061]: output: Attempting to detect a alsa audio device
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_card_dri...ctory
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_concat r...ctory
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib conf.c:4248:(_snd_config_evaluate) function snd_func_refer re...ctory
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib conf.c:4727:(snd_config_expand) Evaluate error: No such file ...ctory
    ene 17 21:00:55 ddich mpd[14061]: ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
    ene 17 21:00:55 ddich systemd[1]: mpd.service: main process exited, code=killed, status=6/ABRT
    ene 17 21:00:55 ddich systemd[1]: Unit mpd.service entered failed state.

  • How do you delete On The Go playlists?

    I accidentely added like 4 playlists to On-The-Go...how do I delete them? Thanks.

    If they were "saved" on the iPod, then they should show up in iTunes the next time you sync. You can then delete them from there.
    If they haven't been saved then go to clear playlist-->clear (music-->playlists-->on-the-go)
    Also, are you updating automatically or manually?
    If manually, then click the little arrow next to the iPod and select the playlists in that list of iPod playlists and hit delete.
    btabz

  • Songs in Playlist will not fit on CD

    Every time I try to burn a cd I get the message:
    "The songs in this playlist will not fit on one Audio Cd. Do you want to create multiple Audio CD's with this playlist spilt across them? This will require more than one blank cd to complete." Then I have the option of clicking Audio CDs or cancel. Nothing happens when I click Audio CDs.
    This happened out of the blue and have not changed any settings. I have tried burning several playlists even one with just one song and still get the same message. So clearly these playlist do not really need more than one cd. I am using the same exact cds that I have successfully been burning with that are CD-R. I just updated to latest version of iTunes as well.
    This is what came up when I ran a diagnostic:
    Microsoft Windows XP Home Edition Service Pack 2 (Build 2600)
    Dell Computer Corporation Dimension 2400
    iTunes 8.2.1.6
    QuickTime 7.6.2
    FairPlay 1.4.10
    iPod Updater Library 8.1d19
    CD Driver 2.1.0.1
    CD Driver DLL 2.1.1.1
    Apple Mobile Device 2.5.2.2
    Apple Mobile Device Driver not found.
    Bonjour 1.0.6.2 (118.5)
    ** CD/DVD Drive Tests **
    LowerFilters: PxHelp20 (2.0.0.0),
    UpperFilters: GEARAspiWDM (2.1.0.1),
    E: Lite-On LTN486S 48x Max, Rev YDS6
    Drive is empty.
    Writing CD text is turned on in the preferences. If you’re having problems burning CDs, try turning this preference off.
    The last failed audio CD burn had error code 4280(0x000010b8). It happened on drive F: _NEC DVD+RW ND-1100A on CDR media at speed 4X.
    F: _NEC DVD+RW ND-1100A, Rev 10FD
    Media in drive is blank.
    Get drive speed succeeded.
    The drive CDR speeds are: 4 8 16.
    The drive CDRW speeds are: 4 8 16 0.
    The drive DVDR speeds are: 4.
    The drive DVDRW speeds are: 4.
    Writing CD text is turned on in the preferences. If you’re having problems burning CDs, try turning this preference off.
    The last failed audio CD burn had error code 4280(0x000010b8). It happened on drive F: _NEC DVD+RW ND-1100A on CDR media at speed 4X.
    PLEASE HELP!!

    If I use a different brand of CD-R it now works (found this suggestion in the answer to another similar question).
    I was using Memorex which didn't work on my PC or Laptop, but works ok on my daughter's PC.
    Maxell works ok.
    Why? Anything I can do to fix it?
    Thanks
    Compaq S5600UK   Windows XP  

  • Restore default Smart Playlist

    I accidently deleted the default “Recently Added” Smart Playlist. I was just attempting to clear that playlist, not delete the folder. Oops, I use it often.
    I have been trying to restore it by creating a new Smart Playlist with the same title, but it’s not working. Perhaps I don’t understand which rules I should be selecting. I’ve tried it a dozen different ways.
    Thanks in advance.

    Have you tried it like this?
    Recently Added:
    Match the rule "Date Added">"is in the last">"1">"Days" make the days and the interval to suit yourself, you can have days, weeks or months.
    Check the box "Live Updating"
    You can read more about smart playlists here:
    How to create a Smart Playlist with iTunes
    Smart Playlists.com

  • Can transfer to playlist, but doesnt show up in library      please help

    I have several songs that i am unable to transfer directly to the library.... they are easily dragged/dropped into a playlist in iTunes, but dont show up in the main library.
    Also they show up as a playlist on my iPhone 4, but again are not found ANYWHERE in the main library..
    After some digging, I was able to find these songs in a folder within the iTunes folder on my PC
    The songs are labeled correctly, yet they show up as "unknown album, unknown artist" but they are clearly labeled .... Im confused and just want to get these songs to appear in the main library of iTunes and also on my phone.
    They appear as a playlist on my iPhone but I cleared the playlist and suddenly they were gone...instantly. 
    I just want these songs on my phone...  (these are mp3's that I have had on my PC for years)

    Have you had a chance to look at these troubleshooting pages? They may be of some help:
    iPod missing in My Computer and in iTunes
    iPod is not recognized properly by computer when USB drivers are not installed properly or are out of date
    If you are using a laptop, this page might help: iPod not recognized when connected to Windows laptop over USB

Maybe you are looking for

  • SMALL ISSUE WITH ALV HIERARCHY

    Hi Hi , I have small doubt in alv hierachail report , can anyone tell me how the header and the item level data match i have iheader and iitem internal tables. say i have matnr in iheader ,do i need to have the matnr field in iitem also so if expand

  • Satellite Z830-10M speakers turn off when lid is closed

    Hi, I am running a Z830-10M with an external monitor. I want to close the laptop lid but use the internal speakers, but when I close the lid, the speakers stop sounding! How do I fix this? Thanks.

  • STARTING UP TOMCAT ON REMOTE WIN2000 SERVER

    Hi all, i have the following problem and i was wondering if any of you has ever come across the same problem as me. I am trying to setup a server/client network. As you can imagine i need to startup tomcat by accessing the actual server machine from

  • Change the permission That limit viewing

    Hi, my sister have downloaded a book from Archambeault with adobe digital edition id. She Made i mistake n'y clicking " to be viewed by only one device." Nos she would Like to transfert her ebook on her ebook reader but the ebook reader can not read

  • Displaying exact playlist length for CD burning

    I like to burn my own CDs of my assorted favorite music, and I like to get as much music into a single CD as I can -- the full 80 minutes. However, iTunes will not display the playlist length in minutes once the length gets over an hour, so I'm force