1
Audio / Sounds stop suddenly
« on: March 21, 2010, 02:34:21 pm »
My apologies, found the problem, I wasn't deleting the instances.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
if (!Music.OpenFromFile("DJYeoh0.ogg"))
{
MessageBox(hWnd,"Failed to load DJYeoh0.ogg.","Warning",MB_ICONEXCLAMATION | MB_OK);
return false;
}
if (!Buffer.LoadFromFile("laser0.ogg"))
{
MessageBox(hWnd,"Failure to load from file.","Warning",MB_ICONEXCLAMATION | MB_OK);
return false;
}
sf::Sound *temp_sound = new sf::Sound;
temp_sound->SetBuffer(ps->app->Buffer);
ps->sound_vec.push_back(temp_sound);
temp_sound->SetPitch(3);
temp_sound->Play();
std::vector<sf::Sound*>::iterator sound_it = sound_vec.begin();
while(sound_it != sound_vec.end()){
int duration = (*sound_it)->GetBuffer()->GetDuration();
int elapsed = (*sound_it)->GetPlayingOffset();
if(elapsed >= duration){
sound_it = sound_vec.erase(sound_it);
}
else
sound_it++;
}