TMci

Source: source/classes/tmci.prg

Standalone class

TMci provides multimedia playback control through the Windows Media Control Interface (MCI) API. It supports audio and video file playback including AVI video, CD audio, WAV, MIDI, and other MCI-compatible devices. The class can play media in a window or full-screen.

Key DATA Members

DATATypeDescription
nErrorNumericLast MCI error code; zero indicates success
nIdNumericMCI device identifier assigned on open
cTypeCharacterDevice type: "AVIVideo", "CDAudio", "WaveAudio", "Sequencer", etc.
cFileNameCharacterPath to the multimedia file being played
oWndObjectParent window for video playback

Methods

MethodDescription
New( cDev, cFile )Create a new MCI object for the given device type and media file
lOpen()Open the MCI device; returns .T. on success
Play( nFrom, nTo, hWnd )Play a segment from nFrom to nTo, optionally in a window handle
PlayFull()Play media in full-screen mode
SetWindow( oWnd )Set the parent window for video output
Position()Return the current playback position
Length()Return the total media length
SendStr( cMci )Send a raw MCI command string directly to the device
cGetError()Return a human-readable description of the last error
End()Close the MCI device and release resources

Example: Play AVI File

#include "FiveWin.ch"

function Main()

   local oMci, oWnd

   DEFINE WINDOW oWnd TITLE "MCI Video Player" SIZE 640, 480

   oMci := TMci():New( "AVIVideo", "sample.avi" )

   if oMci:lOpen()
      oMci:SetWindow( oWnd )
      oMci:Play()
      MsgInfo( "Playing: " + oMci:cFileName )
   else
      MsgStop( "Cannot open: " + oMci:cGetError() )
   endif

   ACTIVATE WINDOW oWnd CENTERED

   oMci:End()

return nil

Notes

See Also