For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > August 2005 > Windows Media Player SDK - VB6 - Play all files in a directory









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Windows Media Player SDK - VB6 - Play all files in a directory
Kurt K.

2005-08-31, 3:59 am

Hi:

I'm a VB newbie. I want my application to play all of the files (.mp3) in a
given directory when I start it. I am able to play a single file by using the
"URL" property of the WMP object.

I'm wondering what the simplest way to pass the contents of a directory to
the player is. All of the files in the directory are mp3s and & want to play
them all. The contents of the directory may change from time to time (I don't
want to manually create a playlist each time...

Any ideas ? Source code please!

Thanks,

kk
Jim Mack

2005-08-31, 7:57 am

Kurt K. wrote:
> I'm a VB newbie. I want my application to play all of the files
> (.mp3) in a given directory when I start it. I am able to play a
> single file by using the "URL" property of the WMP object.


Use Dir() to array the contents of the directory, then set the .URL =
property of the WMP object to each array entry in turn. The =
_PlayStateChanged event of the object will indicate "stopped" when it's =
time for the next one.

Or use the array to create a playlist. That way you're not doing it =
manually, but programatically, and you don't have to pay attention to =
when the next song should play.

Air code, not optimal --

Dim MPNames() As String
Dim nFiles As Long
Dim MP As String

nFiles =3D 0
MP =3D Dir("*.mp3")
do while len(MP)
nfiles =3D nfiles + 1
redim preserve MPNames(1 to nFiles)
MPNames(nFiles) =3D MP
MP =3D Dir()
loop =20

--=20
Jim
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com