How to select a MUSIC File which is in .wav format from a LISTBOX and play that music file on clicking the play BUTTON?

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 !!

Answers (2)

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

I don't want a dialog box to be open. I want to select the songs from a folder which will be in any drive, say C:\Songs. Then I want to display the selected songs in a listbox (the list box have to be static, I don't want a list dialog). Then select a song from the lisbox and play it. Could you please suggest something else?

Sign in to comment.

allstrings = cellstr( get(hObject, 'String') );
curvalue = get(hObject, 'Value');
thisstring = allstrings{curvalue};
[q, Fs] = wavread(thisstring);
sound(q, Fs);

4 Comments

Can you please elaborate your answer because i didn't understand what is allstrings, thisstring and curvalue?
Those are variable names. Put that code into the callback for the listbox.
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.

Sign in to comment.

Categories

Find more on Just for fun in Help Center and File Exchange

Asked:

on 9 Mar 2013

Community Treasure Hunt

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

Start Hunting!