Code: Select all
long BGMPlayer::lSize;
unsigned char * BGMPlayer::buffer;
void BGMPlayer::init(const string soundDir) {
MP3Player_Init();
string filename = soundDir + "ttbgm.mp3";
//char * filename = (char *)"sd:/sounds/ttbgm.mp3";
FILE *fd = fopen(filename.c_str(), "rb");
// obtain file size:
fseek(fd , 0 , SEEK_END);
lSize = ftell(fd);
rewind(fd);
// read the file
buffer = (unsigned char*) malloc (sizeof(unsigned char)*lSize);;
fread (buffer, 1, lSize, fd);
fclose(fd);
}
void BGMPlayer::process() {
if (!MP3Player_IsPlaying()){
MP3Player_PlayBuffer(buffer,lSize,NULL);
}
}
I assume there must have been some changes in this area as I have to link against libasnd in v1.7.1a whereas this isn't the case with 1.7.0.
There also seems to be a bit of a bug in the v1.7.0 mp3player. The last couple of seconds of the MP3 don't seem to get played for me so I have to add some silence to the end.
Any help appreciated.
Thanks,
Toddy