I am trying to create a lamp that turns green while the audio is playing and red after the audio is played. I wrote these lines
function PlayxnButtonPushed(app, event)
if(app.wav_flag == 1 && app.yn_flag ==0)
app.playingxnLamp.Color = 'g';
app.player = audioplayer(app.x, app.fs);
play(app.player,app.fs);
while( strcmp(app.player.running,'on') )
% Waiting for sound to finish
end
app.xn_flag = 1;
end
app.xn_flag = 0;
app.playingxnLamp.Color = 'r';
end
But they create lag that I eventually have to open the task manager to terminate the program. Any idea about what I should be doing? - TIA
Use
playblocking
instead ofplay
. Theplayblocking
function retains control until playing completes.