audioplayer/isplaying won't exit tight loop
Ältere Kommentare anzeigen
When trying to determine when an audioplayer object has finished playing a sound, the following code enters an infinite loop:
aobj = audioplayer(rand(10000,1), 48000, 16, 2);
play(aobj);
while isplaying(aobj)
end
while this code doesn't:
aobj = audioplayer(rand(10000,1), 48000, 16, 2);
play(aobj);
while isplaying(aobj)
pause(0.00001);
end
Can somebody explain what's happening? I'm running Matlab 7.13.0.564 (R2011b) on a Mac, OS 10.7.4. Thank you!
Akzeptierte Antwort
Weitere Antworten (2)
pause and drawnow allow pending events to be processed. This triggers the update of windows, gui elements and even the audioplayer object. See doc pause and doc drawnow .
playblocking(aobj);
1 Kommentar
Tobi S
am 24 Aug. 2012
I have the same problem, but I kind of solved it using:
isempty(aobj)
Return true if the object is empty, which mean, you have not yet load the objet. So, doesn't make sense,at least, stop,pause or resume. I hope that helps.
(Sorry my english).
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!