Audio Player DLL
Well this project involves a lot of things that definitely are
entertaining. It started as a Audio Playing DLL. Vague? You bet.
Anyway, this DLL is nothing more than an MP3 player or was. I started
writing and got more excited everytime and eventually I decided to make
it compatible with XPCOM, and use it to play audio through mozilla.
I actually wrote that piece of code and its stashed somewhere!
Anyway, it was becoming more like a kludge than a library. So I decided
to rewrite it entirely. I separated the code a lot in order for it to become
sort of modular. Now you can actually play OGG's aswell. Can add any
other type of sound aslong as you rewrite the 5 routines required.
Here is how it currently works:
#include "AudioDecoderEngine.h" #include "MP3Library.h" #include <windows.h> #include <stdio.h> #include <time.h> /* This callback only works on MP3s */ void callback(void * data, status ourStatus, void * user_data) { pfData ourData = (pfData)data; pmp3data innerData = (pmp3data)ourData->extraFileData; static int calls = 0; if (calls++ < 1 && ourStatus != STATUS_CLOSING) MP3Layer[innerData->layer], MP3Mode[innerData->mode], MP3Emphasis[innerData->emphasis]); switch(ourStatus) { case STATUS_CLOSING: break; case STATUS_OPENING: break; case STATUS_PLAYING: (ourData->currentFrame*100) / ourData->totalFrames ); break; case STATUS_DONE: calls = 0; break; } } int main(int argc, char **argv) { PAudioLib audio = AUDIO_INIT("D:\\Dream Theater - Another Day.mp3", NULL, callback) int i; AUDIO_LOAD(audio) AUDIO_PLAY(audio, 0) while(audio->playing) { Sleep(2000); } AUDIO_STOP(audio) AUDIO_CLOSE(audio) return 0; }
I am still working on it. I assume its thread safe but I really haven't
checked that thoroughly. Feel free to download and try it out.