views:

23

answers:

1

hi - i am trying to get a database together for a community radio station. i am a newbie at this but would like to be able to display only wav files from a directoy (can get all files using dirlistbox but cant work out how to filter them down). then would like to able to highlight a file from the list, hit a button and play it. thanks for any help. rob

A: 

Well, getting the list of files with WAV extension from a folder is easy:

  Dir("C:\Audio\*.WAV")

You'd then call that to populate your listbox, which you seem to be doing already without filtering for file extension. You might also want to use the File System Object instead, as it's more likely to handle post-Vista security better than VBA's Dir(), which does not.

For playing, it's complicated. You have to decide what you're going to use to play them. You could use Application.FollowHyperlink, which will open the files in whatever application is set as the default player for WAV files.

But that might result in undesirable side effects, such as spawning multiple instances of the app, or, in the case of Windows Media Player, which does not support multiple instances, you'd end up with only the last one playing.

It may be that you need to learn how to create a playlist file, which you'd write on the fly after walking through the listbox's .Selected collection, and then using Application.FollowHyperlink with the playlist file. So far as I can tell, the two most common formats for playlists are M3U and PLS, explained in the linked Wikipedia articles for each. Other formatas are ASX, XSPF and WPF. These latter three formats all use XML. If I was using a player that supported M3U, that's what I'd use, as it's by far the simplest of the formats.

David-W-Fenton