MCIWnd Control (VBCCRMCIWnd)
The MCIWnd control is a Media Control Interface (MCI) window control used for playing multimedia files. It supports various media formats, including audio files (such as WAV, MP3, MIDI) and video files (such as AVI, MPG, WMV).
Properties
Basic Properties
FileName
- Current media file nameDeviceType
- Device typeTimeFormat
- Time formatMode
- Current playback modePosition
- Current playback positionLength
- Media file lengthVolume
- Volume (0-1000)Speed
- Playback speedZoom
- Video zoom ratioChannel
- Audio channelEnableContextMenu
- Whether to enable context menuNotify
- Whether to enable notification eventsWait
- Whether to wait for command completion
Status Properties
IsPlaying
- Whether currently playingIsPaused
- Whether pausedIsOpen
- Whether file is openCanPlay
- Whether can playCanRecord
- Whether can recordCanSave
- Whether can saveCanWindow
- Whether can display windowCanEject
- Whether can eject
Events
PlayCompleted
- Triggered when playback completesRecordCompleted
- Triggered when recording completesPositionChange
- Triggered when playback position changesModeChange
- Triggered when playback mode changesMediaError
- Triggered on media errorDeviceError
- Triggered on device errorClick
- Triggered when control is clickedDblClick
- Triggered when control is double-clickedMouseMove
- Triggered when mouse moves
Code Examples
Basic Playback Functions
vb
Private Sub InitMCIWnd()
With MCIWnd1
.EnableContextMenu = True
.Notify = True
.TimeFormat = "ms" ' Use milliseconds as time unit
.Volume = 1000 ' Maximum volume
End With
End Sub
Private Sub PlayMedia(ByVal FilePath As String)
With MCIWnd1
' Close current file
If .IsOpen Then
.Close
End If
' Open and play new file
.FileName = FilePath
.Play
End With
End Sub
Private Sub StopMedia()
With MCIWnd1
If .IsPlaying Then
.Stop
End If
End With
End Sub
Private Sub PauseMedia()
With MCIWnd1
If .IsPlaying Then
.Pause
End If
End With
End Sub
Private Sub ResumeMedia()
With MCIWnd1
If .IsPaused Then
.Play
End If
End With
End Sub
Player Manager
vb
Private Type MediaInfo
FilePath As String