MATLAB: Using timer in GUI to change a textbox

gui timerMATLAB

Hello,
I wrote a GUI for sound recording. I have buttons for record, stop and play and a static box. When I click the play button, the static box displays "playing", and I am trying to set a timer to automatically change the static box to "ready to record" which the code attached. However it doesn't work. Can any one tell me what is the write way to set up a timer? Thank you!!
function playButtonPushed(app,~,~)
app.readyLabel.String='recording playing'
T = timer('StartDelay',3,'TimerFcn',@(~,~) set(app.readyLabel,'String' 'r'));
start(T)
sound(getaudiodata(app.AudioRecorder),app.AudioRecorder.SampleRate)
end

Best Answer

You do not need to use a timer for this. You can use audioplayer() with either play() or playblocking(). audioplayer objects have a StopFcn callback that fires at the end of the audio.
Related Question