stopping Windows Media Player using VBA

M

Malone

I've been trying to write some code which will start playing an audio file and then stop after a certain number of seconds. I've tried this:-

sub testcode ()

Dim wmp as WindowsMediaPlayer

Set wmp = New WindowsMediaPlayer

wmp.URL = "C:\audio\test.mp3"

wmp openPlayer (wmp.URL)

Application.Wait Now() + TimeSerial(0, 0, 10)

wmp.Controls.stop

End Sub

It opens the player ok and plays the file but then it doesn't stop after 10 sec.

wmp.playState tells me it is stopped - but the player keeps going. Is wmp.Controls.stop the wrong command?

I'm not too experienced with this sort of thing so I may be making a really silly mistake. Can anyone tell me what it is?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top