Wednesday, April 28, 2010

Updates to the MP3 Player

I've been making the whole MP3 player a lot more robust than it used to be. What I had was based on code I had originally written maybe 6 or 7 years ago, and included in an MHQuake from that time. It worked fine so I just restructured some of it a little, but otherwise it's probably the oldest actual lines of code in DirectQ.

First off is that it now picks up music from your gamedir correctly, using the correct fallback order of gamedir/expansion pack(s)/ID1 for searching.

Secondly is that I've removed the ability to set a music dir via a cvar. Now it's just music/ and sound/cdtracks/ that get searched.

Thirdly is that I've modified the looping code a little. It no longer waits for DirectShow messaging but instead polls the current position every few frames. We all know that polling is BAD and EVIL and MUST BE DESTROYED but nonetheless in a game engine which is going to hog your CPU anyway, normal rules don't apply. DirectShow messaging proved unreliable, polling will work. I do it every few frames so that it won't impact on performance, but in practice even doing it every frame is OK.

Fourthly is that it's now able to stream an m3u or any other type of container from the web.

What it doesn't do yet is play tracks from PAK/PK3/ZIP files. This is just a matter of extracting the file to your temp folder and playing it from there (and remembering to clean up by deleting it when finished).

1 comments:

Andy said...

(and remembering to clean up by deleting it when finished)

Something tells me you've a mother somewhere that has just now experienced the world of computing? Odd, for I'd uttered the exact same phrase (more or less) to mine this weekend.

God help me the weekend the two of us discuss MP3s, etc. . .