FreeFoote's Arbitrary Internet Home

FreeFoote

Home About FreeFoote Contact FreeFoote

Linux Projects

GPS Photo Correlator EXIF Utility Scripts Sound Scope LCDMenu MPG123 HTTP patch Remote Download Manager

Hardware Projects

Cut down keyboard mod Sprinkler Controller

Abandoned Projects

The CFW

About the CFW Background Images Next Version: CFW3 Current Version Download Email Lists Screenshots Source Code

The F3C

About the F3C Contribute Documentation Download

MPG123 HTTP Song Length Patch

What does it do?

mpg123 is a great little MP3 player, even if it isn't quite as free as other players.

But it, like almost any other MP3 player, can not show you the length of a song when you stream it from HTTP. Well, that is, until I saw another player do it. We can't have non-free software doing things like this exclusively!

So I took mpg123-pre0.59s and changed a few things, and ended up with a version of mpg123 that could indeed determine the length of a song being streamed from HTTP, but only once it started playing. But now I can have my countdown timer in my MP3 player... much nicer...

I contacted the author of mpg123 several times over about 9 months, without a response. I've finally given up, and I'll just post the patch here. If you are the author, or know the author, please contact me and we can sort something out.

Download the patch

You can download the patch here (4k).

It was done against mpg123-pre0.59s, so if you have another version, you might need to tweak it a bit. See how you go.

Apply the patch with:

$ cd mpg123
$ patch * < mpg123-http-song-length-patch.patch

and then compile and install as usual.

What did I do to it?

How many thousands of lines of code did I change? Well, not that many, actually...

  1. I modified the function http_open() in httpget.c to retain the length of the file that is returned. To do this, I had to modify the function to take two parameters: firstly, the URL, and secondly, a pointer to an integer variable to store the length of the file.
  2. The change in (1) created several changes in various places, to call the new function. The main ones are in playlist.c and readers.c.
  3. Finally, the functions print_stat() (in common.c) and generic_sendstat() (in control_generic.c) was modified to make use of the file length, and also to not try to get the current position of the file in the case of a HTTP stream.

But have fun with the patch... if you can make it better, then by all means do so...

  FreeFoote, aka Daniel Foote - freefoote [at] dview [dot] net