0

I want to make a simple MP3 player using BASS library. I have this code :

BASS_Init(-1, 44100, 0, 0, NULL);
qDebug() << BASS_ErrorGetCode();
HSTREAM stream = BASS_StreamCreateFile(FALSE,"C:/1.mp3", 0, 0, 0);
qDebug() << stream;
qDebug() << BASS_ErrorGetCode();
BASS_ChannelPlay(stream, FALSE);
qDebug() << BASS_ErrorGetCode();

This code compiles fine, but when i launch my program the MP3 seems to be not played while the output seems to be normal :

0 
2952790017 
0 
0 

Do you have a solution ?

gcdu97
  • 25
  • 8
  • Aren't paths in Windows using a backslash? This means you should use `C:\\1.mp3` for the filename. The double backslash it's to escape it in the string. – Anya Shenanigans Apr 11 '15 at 15:48
  • Thanks for your reply ;) I've tried what you said and nothing changed. Also, the program uses 1% of CPU, so it seems to be doing something... – gcdu97 Apr 11 '15 at 16:03

1 Answers1

0
  1. "C:/1.mp3" should be ok.
  2. You should also check your standard device (which is -1). You can use this code to list all your devices (and maybe change -1 to the device you are definitely using):

(copied from web and changed for better output)

int a, count = 0;
BASS_DEVICEINFO info;

for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{
    cout << "BASS_GetDeviceInfo " << a << ": ";
    if (info.flags & BASS_DEVICE_ENABLED)
    {
        count++;
        cout << "enabled  --> ";
    }
    else
    {
        cout << "disabled --> ";
    }
    cout << info.name << endl;
}
cout << "count: " << count << endl;
  1. Make sure your volume is set: BASS_SetVolume(1);
  2. Wait for keypress and clean up:

after you call BASS_ChannelPlay

system("pause");
BASS_Free();