MATLAB Answers

Firzi Mukhri

how to block push button after pressed?

Asked by Firzi Mukhri
on 25 May 2013

I have 4 push button on my GUI. One 'play' button, one 'poor' button, one 'okay' button, one 'good' button.

the program start by clicking 'play' button that will play a sound.

the user will then have to grade the song using the other 3 button, either 'poor', 'okay' or 'good'.

after the user grade the song, the 3 button is programmed to call the 'play' button function, and next song will be played.

the problem is, if the user pressed the play button 'again' without grading the song. next song will be played leaving the last song to skip and not graded. Does anyone have any idea how to prevent this? Thank you.



No products are associated with this question.

1 Answer

Answer by Image Analyst
on 25 May 2013
 Accepted answer

Just have the Play button call a function you write called PlayNextSoundFile(). Then for the other 3 button callbacks, you do

function btnGood_Callback(hObject, eventdata, handles)
  % Log score for this song.
  songNumber = handles.songNumber; % Increment this in PlayNextSoundFile
  handles.songScore(songNumber) = 2; % or whatever.
  % Play the next sound file.  Also increments handles.songNumber.

Same thing for the okay and poor callbacks. Set the score to whatever number you want to use to rate them good, poor, or okay. Or alternatively you could put up a slider or a bunch of radio buttons to get the user's rating of that song.


Firzi Mukhri
on 25 May 2013

will this solve the skipping problem? because if the user press the play button again without answering 'poor' or 'okay' or 'good'. Next song will be play by the 'play' button.

I do not want the user to skip grading the song played.

Image Analyst
on 25 May 2013

If the user clicks the play button, you can call PlayCurrentSong(handles) to replay the current song only, and so then it won't increment to the next song and play the next song.

Firzi Mukhri
on 25 May 2013

Thanks! I understand now.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!