#6 Loop option

closed
nobody
5
2004-10-08
2002-10-30
Anonymous
No

I use mpg321 for photo slideshows (with qiv showing the
photos.) It works like a charm. Thank you for a great
mp3 player!

Any chance that a loop option might be added? One
that would allow all the command line arguments or the
playlist to be looped. Perhaps, even the ability to loop it
a specific number of times, or indefinitely.

Again -- great program! Thank you!
Darin

Discussion

  • Logged In: YES
    user_id=719421

    I added this function. I hope it will meet your needs.
    Patches (beware, some lines have been splited up):

    --- mpg321.h 2002-03-23 23:45:31.000000000 +0100
    +++ mpg321.h.new 2004-06-19 16:27:58.000000000 +0200
    @@ -109,6 +109,7 @@
    extern int quit_now;
    extern char remote_input_buf[PATH_MAX + 5];
    extern int file_change;
    +int loop_remaining;

    extern int status;

    --- mpg321.c 2002-03-24 06:49:20.000000000 +0100
    +++ mpg321.c.new 2004-06-19 16:28:05.000000000 +0200
    @@ -85,7 +85,7 @@
    " --skip N or -k N Skip N frames into the
    file\n"
    " --verbose or -v Be more verbose in
    playing files\n"
    " -o dt Set output devicetype
    to dt\n"
    - "
    [esd,alsa(09),arts,sun,oss]\n"
    + "
    [esd,alsa(09),arts,sun,oss]\n"
    " --audiodevice N or -a N Use N for audio-out\n"
    " --stdout or -s Use stdout for
    audio-out\n"
    " --au N Use au file N for
    output\n"
    @@ -95,6 +95,8 @@
    " --list N or -@ N Use playlist N as list
    of MP3 files\n"
    " --random or -Z Play files randomly
    until interrupted\n"
    " --shuffle or -z Shuffle list of files
    before playing\n"
    + " --loop N or -l N Play files N times. 0
    means until\n"
    + " interrupted\n"
    " -R Use remote control
    interface\n"
    " --aggressive Try to get higher
    priority\n"
    " --help or --longhelp Print this help screen\n"
    @@ -235,6 +237,8 @@
    exit(1);
    }

    + loop_remaining = 1;
    +
    options.volume = MAD_F_ONE;

    status = MPG321_PLAYING;

    --- options.c 2002-02-17 06:48:59.000000000 +0100
    +++ options.c.new 2004-06-19 16:28:25.000000000 +0200
    @@ -99,6 +99,7 @@
    { "wav", 1, 0, 'w' },
    { "audiodevice", 1, 0, 'a' },
    { "gain", 1, 0, 'g' },
    + { "loop", 1, 0, 'l' },
    { 0, 0, 0, 0 }
    };
    int option_index = 0, c;
    @@ -107,7 +108,7 @@

    while ((c = getopt_long(argc, argv,

    "OPLTNEI824cy01mCu:d:h:f:b:p:r:G:" /* unimplemented */
    -
    "A:D:vqtsVHzZRo:n:@:k:w:a:g:", /* implemented */
    +
    "A:D:vqtsVHzZRo:n:@:k:w:a:g:l:", /* implemented */
    long_options, &option_index)) != -1)
    {
    switch(c)
    @@ -239,6 +240,12 @@
    options.volume = (options.volume/100.0) *
    MAD_F_ONE;
    break;

    + case 'l':
    + loop_remaining = atoi(optarg);
    + if (!loop_remaining)
    + loop_remaining = -1;
    + break;
    +
    case 'I':
    /* We only try to get high priority. If it
    fails (just as
    mpg123 does when run as a user), that's
    fine */

    --- playlist.c 2002-03-24 06:50:12.000000000 +0100
    +++ playlist.c.new 2004-06-19 16:28:16.000000000 +0200
    @@ -136,6 +136,12 @@
    if (!pl->random_play)
    {
    if (i == pl->numfiles)
    + {
    + i = 0;
    + if (loop_remaining != -1)
    + loop_remaining--;
    + }
    + if (!loop_remaining)
    return NULL;

    return pl->files[i++];

     
  • Logged In: YES
    user_id=712646

    This patch has been added to the current development tree.
    Hopefully I will have time to finish up a release soon.

     
    • status: open --> closed