How do I pause execution until file has finished playing using the MediaPlayer control?



Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here




From: Geoff Bird
Date: Fri 12/07/2002 21:44
Subject: Media PLayer in VB6
Question: Hello,

I was wondering if you could help me. I have seen your excellent media player on the web and I wondered if I could ask you a question. When using the mediaplayer, is there a way to suspend program execution until the file being played has finished.

So that if you write

then the file would play until the end.

Thanks very much for any help you could give,

Geoff Bird

The following code may help you with this problem:

MediaPlayer1.FileName = "C:\WINDOWS\MEDIA\ONESTOP.MID"
Me.Enabled = False

Do While MediaPlayer1.PlayState = mpPlaying

Me.Enabled = True
MsgBox "song has finished"

Martin Allen 1999 - 2011.  Last updated Saturday 13 August 2011 12:11:15 AM +0100.