Is there a way to open music and play it?

조회 수: 36 (최근 30일)
Rainaire Hansford
Rainaire Hansford 2018년 7월 5일
댓글: Rahul Gulia 2022년 3월 7일
Is there a way for MATLAB to read all music files and work like a music player
  댓글 수: 1
Rahul Gulia
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
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)
You can find more info about 'audioplayer' here
  댓글 수: 12
Rainaire Hansford
Rainaire Hansford 2018년 10월 17일
Ok I tried running this code and put in the directory but it was keep given me error. Could some share a example code I might be missing something.
Sorry for taking so long.
Walter Roberson
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
Rainaire Hansford 2018년 10월 21일
Yes I got it thank you. Now next step is to implement pause and stop and play in this code cause I really need it lol But Walter your the best
  댓글 수: 1
Walter Roberson
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 CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by