Is there a way to open music and play it?
13 次查看(过去 30 天)
显示 更早的评论
Is there a way for MATLAB to read all music files and work like a music player
1 个评论
Rahul Gulia
2022-3-7
How can we play Youtube songs links like this? I tried using the webread() function, but it gives me an error "Too many output arguments".
采纳的回答
Anton Semechko
2018-7-5
Yeah, there is a way. Here is an example:
% Get sample audio file from the web
[y,Fs]=webread('http://www.worldnationalanthem.com/wp-content/uploads/2015/05/canada-national-anthem-mp3-free-download.mp3');
% Create a 'player' object
PO=audioplayer(y,Fs);
% Play audio
play(PO)
% Stop audio
%stop(PO)
12 个评论
Walter Roberson
2018-10-17
fullname = 'C:\Users\rain\Documents\MATLAB\ProjectGreen\abalone_sound7.wav'; %change as required
try
[y, Fs] = audioread(fullname);
PO=audioplayer(y,Fs);
% Play audio
playblocking(PO)
catch ME
uiwait(msgbox('Could not open that file with audioread'));
end
更多回答(1 个)
Rainaire Hansford
2018-10-21
1 个评论
Walter Roberson
2018-10-21
Use play() instead of playblocking() . Then put in a button that uses the pause() method on the audioplayer object.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!