How to select a MUSIC File which is in .wav format from a LISTBOX and play that music file on clicking the play BUTTON?
Show older comments
I want to add songs in a listbox and select the song which I have added in the listbox and play it. I have successfully added the songs in a listbox. But I don't know how to select the song from listbox and play that song. As I am a newbie, I don't know much about guide. Please help me. Please !!
1 Comment
Walter Roberson
on 15 Mar 2013
Please read the guide to tags and retag this question. In particular please do not use the name of individuals as tags. See http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
Answers (2)
Azzi Abdelmalek
on 9 Mar 2013
d = dir('*.wav');
str = {d.name};
[s,v] = listdlg('PromptString','Select a sound:',...
'SelectionMode','single',...
'ListString',str)
q=wavread(str{s})
sound(q)
1 Comment
Puneet Popli
on 13 Mar 2013
Walter Roberson
on 13 Mar 2013
allstrings = cellstr( get(hObject, 'String') );
curvalue = get(hObject, 'Value');
thisstring = allstrings{curvalue};
[q, Fs] = wavread(thisstring);
sound(q, Fs);
4 Comments
Puneet Popli
on 15 Mar 2013
Walter Roberson
on 15 Mar 2013
Those are variable names. Put that code into the callback for the listbox.
Image Analyst
on 15 Mar 2013
You can also use handles.listbox1 instead of hObject if you want, where listbox1 is the "tag" property that you see in the property inspector. Launch GUIDE, click the listbox and drag out a listbox on your GUI, then double click on it. Please see the excellent GUIDE videos on Doug Hull blog.
Puneet Popli
on 19 Mar 2013
Categories
Find more on Just for fun in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!