MATLAB: How play wav files selected from a playlist/listbox

audio playerlistboxMATLABplaylist

I have created a GUI audio player that plays wav files. The player has an add button that selects a file from a folder and plays it.
I am able to populate the listbox/playlist with the appropiate wav files, but cant figure out how to actually play the selcted file. At the moment it just plays 1 audio file named 'handel.wav'. I would appreciate some input on how to make the player play more than just one song from the playlist. I have inlcuded the code for my player from the opening fcn and the code for the add button which puts the wav file in the listbox. There is no code in my listbox yet and just play, pause and stop buttons elsewhere.
Screenshot from 2018-12-13 22-31-02.png
Screenshot from 2018-12-13 22-27-14.png

Best Answer

Is that your working code or an example?
For what you show, you have hard-coded the openingFcn to load and play 'handel.wav'. Your audioread does not accept variable input.
If you want it to play something else, you'll have to pass the pathname and filename to the selected wav file to auidoread.
BTW - better practice to copy and past the actual code instead of screenshots.
Related Question