Re: Windows Media Player msdxm.ocx control on Vista



"Alan Scott" <AlanScott@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:18806703-4542-4677-9B16-EC3FB80B3A36@xxxxxxxxxxxxxxxx

I have a VB6 application that has always used the Windows Media 6.4
msdxm.ocx api for audio playback support. This worked fine on all
versions of Windows and Windows Media Player up to and including
Windows XP SP-2 and Windows Media Player 11. However, the
application will not play any audio on Vista . . .

Now there's a coincidence (well, almost a coincidence!). I usually use the PlaySound API for playing wav files and I found that it did not work in Vista. I eventually realised that PlaySound in Vista does not play mono wavs, although it is fine with stereo wavs. Anyway, to cut a long story short (as they say in this neck of the woods) by the time I realised the "mono versus stereo" problem I had already started to move along a different route altogether. I came across the VB ActiveMovieControl type library (aka c:\windows\system32\quartz.dll) which is normally present by default on virtually all XP and Vista (and many earlier) systems and which therefore does not even need to be registered. It is completely configurable from within your VB programs and you can do all sorts of things with it, but "boiled down to its basics" you can play stuff with just four simple and very short lines of VB code (although you can of course do a lot more than simply "play" the file if you add more code). And (my old teacher always told me never to start a sentence with "And"!) you can do a lot more than play wav files with it. The same four lines of VB code can also play mid tunes and mp3 songs and even mpeg video files! Using just the simple code the video plays in its own window (separate from your VB Form) but it is easy to add extra code so that the video plays in a suitable container on your Form (a Picture Box, for example).

Anyway, here's the code. You need to use the Project / References menu to set a reference to ActiveMovieControl type library. If you can't see it in the list then click the Browse button and look for quartz.dll in your Windows/System32 folder. If you cannot find it then you'll need to install DirectX. This code does limit you to systems that have DirectX installed, but these days that's just about all of them (at least "all of them" on systems where the user is interested in your sounds playing at all!).

Mike

.. . . oops. Almost forgot the code. Here it is. At its most basic level there isn't much to it. By the way, I highly recommend the "bad moon rising" song (Credence Clearwater Revival) ;-)

Private Sub Command1_Click()
Static player1 As Object
Set player1 = New FilgraphManager
player1.RenderFile "c:\bad moon rising.mp3"
player1.Run
End Sub






.