Stop audio from playing using sound()
564 views (last 30 days)
Matlab Online (ver R2018b)
I'm playing some audio using sound(y,Fs) but I can't find a way to stop the audio from playing. You can guess that it gets even worse when you (accidentally) execute the command twice (yes it plays the music over eachother instead of replacing it). Refreshing the page is the only option for now.
I know you can use audioplayer(y,Fs) for offline versions but it won't work online.
More Answers (2)
Joe V on 27 Jun 2019
works but isn't documented (h/t Li Kang: https://www.mathworks.com/matlabcentral/answers/99704-how-can-i-interrupt-the-playback-of-an-audio-file-that-has-been-initiated-using-wavplay-in-matlab-7#answer_246119)
MUHAMMAD HAIDIEL SHAFIS BIN MAZELAN on 6 Jan 2021
lol u guys can also use this too...
[a, fs] = audioread('yourfilehere.mp3');
fs =1.0*fs; %%We can adjust our speed of our song by multiplying our fs with any desired numbers.
y = input ('Press 1 to stop the music: ');
fprintf ('You didn''t enter 1 ');