The function works for me. pause and play are displayed in the command window. Please see testpauseplay app attached.
If you want a play/stop button for your slider, you could use a pushbutton and change it's text and icon after being clicked.
See video player app attached if that is something you would be interested in (snippet of code below).
if app.PlayButton.Text == "Play"
app.PlayButton.Text = "Stop";
app.PlayButton.Icon = "IconEnd.png";
while hasFrame(app.vidObj)
vidFrame = readFrame(app.vidObj);
imshow(vidFrame,'Parent',app.UIAxes)
pause(1/app.vidObj.FrameRate);
if app.PlayButton.Text == "Play"
disp('Loop stopped by user');
break;
end
end
else
app.PlayButton.Text = "Play";
app.PlayButton.Icon = "IconPlay.png";
end