Idea: Detect the current file playback status in the Timer control, if you are stopped, then repeat Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As LongPrivate Sub Command1_Click () Timer1.Enabled = TrueTimer1.Interval = 100Call McISendstring ("Close All", 0, 0, 0) 'First closes all MCI devices, avoid playing multiple music files, overlapping Call McISendstring ("Open" "C: /Winnt/Media/ringin.wav" , 0, 0, 0) 'Open the MCI device Call McIndString ("Play" "C: /Winnt/Media/ringin.wav", 0, 0, 0) play MCI device end subsprivate sub timer1_timer ()
Dim Buffer AS String * 128Dim POS AS Integer McIndstring "Status C: /Winnt/Media/ringin.wav Mode", Buffer, 128, 0 &
POS = INSTR (Buffer, Chr (0)) IF Left (Buffer, POS - 1) = "Stopped" THEN CALL MCISENDSTRING ("Close All", 0, 0, 0) Call McIndString ("Open" "C: / Winnt / Media / Ringin.wav ", 0, 0, 0) Call McIndstring (" Play " " C: /Winnt/Media/ringin.wav ", 0, 0, 0) End IFEND SUB