Your message dated Mon, 25 Feb 2013 23:11:57 +0100
with message-id <[email protected]>
and subject line Re: mpc: Playlist numbering is off-by-one
has caused the Debian Bug report #700219,
regarding mpc: Playlist numbering is off-by-one
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
700219: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700219
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: mpc
Version: 0.19-2
Severity: normal

*** Please type your report below this line ***

I regularly use (via a local emacs mode) the formatting optiona
available in the playlist-display to choose my next song.

This example will make it clear:

    * I'm trying to dump all songs in the playlist, along with
      their numbers.

precious ~ $ mpc --format='%id% - %file%' playlist  | head -n 10
0 - Abba/Abba - Dancing Queen.mp3
1 - AC-DC/Back In Black/Hells Bells - AC-DC - Back In Black - 01.mp3
2 - AC-DC/Back In Black/Shoot To Thrill - AC-DC - Back In Black - 02.mp3
3 - AC-DC/Back In Black/What Do You Do For Money Honey- - AC-DC - Back In Black 
- 03.mp3
4 - AC-DC/Back In Black/Givin The Dog A Bone - AC-DC - Back In Black - 04.mp3
5 - AC-DC/Back In Black/Let Me Put My Love Into You - AC-DC - Back In Black - 
05.mp3
6 - AC-DC/Back In Black/Back In Black - AC-DC - Back In Black - 06.mp3
7 - AC-DC/Back In Black/Have A Drink On Me - AC-DC - Back In Black - 08.mp3
8 - AC-DC/Back In Black/Shake A Leg - AC-DC - Back In Black - 09.mp3
9 - AC-DC/Back In Black/Rock And Roll Ain't Noise Pollution - AC-DC - Back In 
Black - 10.mp3


So now I have the ID of each song, and the name.

Let us pretend that song 10 is currently playing.  Let us play song 0:

precious ~ $ mpc play 0
AC-DC - Rock And Roll Ain't Noise Poll
[playing] #10/10246   0:04/4:26 (1%)
volume: n/a   repeat: on    random: on    single: off   consume: off

Here you see there is "magic behaviour".  Attempting to play song 0
will show the details for the currently-playing song.  It will not
play song zero.

If I wish to play Abba, the first song in the list above, I must choose
track 1:

precious ~ $ mpc play 1
Abba - Dancing Queen
[playing] #1/10246   0:00/6:33 (0%)
volume: n/a   repeat: on    random: on    single: off   consume: off

The conclusion?  The playlist-formatting should start the ID at 1, not
0.

Patch attached:

--- util.c  2013-02-10 00:43:30.000000000 +0000
+++ util.c~ 2013-02-10 00:43:22.000000000 +0000
@@ -245,7 +245,7 @@
        snprintf(buffer, sizeof(buffer), "%d", pos+1);
        value = buffer;
    } else if (strcmp(name, "id") == 0) {
-       snprintf(buffer, sizeof(buffer), "%u", mpd_song_get_id(song)+1);
+       snprintf(buffer, sizeof(buffer), "%u", mpd_song_get_id(song));
        value = buffer;
    } else {
        enum mpd_tag_type tag_type = mpd_tag_name_iparse(name);

-- System Information:
Debian Release: 6.0.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages mpc depends on:
ii  libc6                         2.11.3-4   Embedded GNU C Library: Shared lib
ii  libmpdclient2                 2.3-1      client library for the Music Playe

mpc recommends no packages.

Versions of packages mpc suggests:
ii  mpd                           0.16.7-2   Music Player Daemon

-- no debconf information

--- End Message ---
--- Begin Message ---
Hi Steve,

thanks a lot for your bug report and for going to the lengths of
providing a patch. Unfortunately, I think you've been caught up in
the subtleties of %id% vs %position%. Quoting from MPD's protocol
documentation:

        For manipulating playlists and playing, there are two sets of
        commands.  One set uses the song id of a song in the playlist,
        while another set uses the playlist position of the song. The
        commands using song ids should be used instead of the commands
        that manipulate and control playback based on playlist
        position. Using song ids is a safer method when multiple
        clients are interacting with MPD.

So these two are not the same thing, and it seems that contrary to the
above recommendation, mpc uses positions. mpc(1) does not mention %id%
anywhere, but documents %position% and the fact that the play command
takes an optional position argument. So, if you use

    mpc --format='%position% - %file%' playlist | head -n 10

you will get the correct numbers to feed to 'mpc play'.

I'm thus closing this bug.

Florian

--- End Message ---

Reply via email to