Skip to content

Commit 4da91a4

Browse files
committed
soundplayer: Fixed auto play not working when async loading
1 parent 427ffd7 commit 4da91a4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ofxSingleSoundPlayer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool ofxSingleSoundPlayer::loadAsync(std::filesystem::path filePath, bool bAutop
9292

9393
setState(bAutoplay?LOADING_ASYNC_AUTOPLAY:LOADING_ASYNC);
9494
bStreaming = false;
95-
ofAddListener(soundFile->loadAsyncEndEvent, this, &ofxSingleSoundPlayer::initFromSoundFile);
95+
ofAddListener(soundFile->loadAsyncEndEvent, this, &ofxSingleSoundPlayer::initFromSoundFile, std::numeric_limits<int>().min());
9696
soundFile->loadAsync(filePath.string());
9797

9898
return true;
@@ -191,8 +191,9 @@ void ofxSingleSoundPlayer::initFromSoundFile(){
191191
ss << "Not streaming; Reading whole file into memory!\n";
192192
}
193193
}
194-
// load(soundFile->getBuffer(), name);
195-
// }else{
194+
195+
bool bIsAsyncAutoplay = isState(LOADING_ASYNC_AUTOPLAY);
196+
196197
volume.setName(name);
197198

198199
initFromSoundBuffer(soundFile->getBuffer());
@@ -203,7 +204,7 @@ void ofxSingleSoundPlayer::initFromSoundFile(){
203204
}
204205

205206

206-
if(isState(LOADING_ASYNC_AUTOPLAY)){
207+
if(bIsAsyncAutoplay){
207208
setState(LOADED);
208209
play();
209210
}else{

0 commit comments

Comments
 (0)