Music is back!
I've revisited some old DirectShow code and had a great time trying to figure out how the thing works all over again. It's pretty much in there now, but as a supplement to rather than a replacement for the original CD player. Basically if there is no CD in the drive it attempts to fall back on MP3s or whatever (I'll come to that in a bit...) before giving up.
Aside from the fact that the music files must be in a directory called "music" under your gamedir (some day I'm going to cvar-ize all of these fixed directories I've created) I've removed all limitations on the names. So you can have 10 files called whatever you want and I'll play them in order for you. Nice.
What about formats? That's where the really nice thing (one of them anyway) about DirectShow comes in. It'll play almost anything; if you can play it in Windows Media Player then this baby will play it for you too. Theoretically it can even stream audio over the internet, but I haven't added code for that (don't think I will, somehow...)
Experiences with DirectShow were mixed. I know my initial implementation from years ago was a mess, and the first shot I'd taken at it this time was getting real ugly real fast too, so I ended up wrapping all of the DirectShow stuff in a class and using that to manage my COM pointers and stuff. It was much much cleaner overall, but there are still some weird things in the API itself that had me doing some head-scratching for a bit. Never mind.
At this stage a massive shout out needs to go to http://www.flipcode.com - they have some excellent resources, containing exactly the kind of info you need to implement DirectShow in this kind of app, which really helped with getting back up to speed.
And no thanks at all to http://msdn.microsoft.com.
Thursday, December 25, 2008
Music is back!
Posted by mhquake at 9:58 PM