[almp3] Music won't play
Johan Halmén

I can't get a mp3 file to play.

This is my code:

1 ALMP3_MP3 *mp3;
2 mp3 = almp3_create_mp3(my_data[SONG1].dat, my_data[SONG1].size);
3 if (!mp3)
4 {
5 alert("Failing using data file memory", "", NULL, "Ok", NULL, 0, 0);
6 return;
7 }
8
9 if (almp3_play_mp3(mp3, 32768, 255, 128) == ALMP3_PLAY_BUFFERTOOSMALL)
10 {
11 alert("mp3 buffer too small", "", NULL, "Ok", NULL, 0, 0);
12 return;
13
14 }
15 int result=9999, j = 0;
16 
17 do
18 {
19 result = almp3_poll_mp3(mp3);
20 rest(200);
21 textprintf_ex(screen, font, 60, 60, 0, 0x00ff00, " %d %d", almp3_get_pos_frames_mp3(mp3), j++);
22 }
23 while (result == ALMP3_OK && !key[KEY_ESC]);
24 if (result == ALMP3_POLL_PLAYJUSTFINISHED)
25 alert("Finished", "", NULL, "Ok", NULL, 0, 0);
26 if (result == ALMP3_POLL_NOTPLAYING )
27 alert("Not playing", "", NULL, "Ok", NULL, 0, 0);
28 if (result == ALMP3_POLL_FRAMECORRUPT )
29 alert("Corrupt", "", NULL, "Ok", NULL, 0, 0);
30 if (result == ALMP3_POLL_INTERNALERROR )
31 alert("Error", "", NULL, "Ok", NULL, 0, 0);
32
33 alert("Ended", "in <esc>", NULL, "Ok", NULL, 0, 0);
34 almp3_destroy_mp3(mp3);

It gets stuck in the do{} thing with polling and textprintf. The frame first shows 14, then 28, then it's stuck right there. The j++ increases all the time but the frame position is stuck at 28. And the poll returns ALMP3_POLL obviously all the time. I've tried to change the mp3 file. A strange thing is that I tried also to recompile an older project that always have managed to play an mp3, but now it didn't. Could the almp3 source be corrupted? But that's only a dll, a lib file and a .h file.

CGamesPlay

It could be any number of things, but yes, try to recompile almp3.

Thread #588054. Printed from Allegro.cc