Multimedia with API in VB

zhaozj2021-02-17  54

Using API in VB is mainly to call Windows MMSystem.dll library. The following is a statement to call the API (these code are placed in the declaration section of the program):

1. 'Play the statement required by CD and AVI.

Declare function mcIndstring lib "mmsystem" (Byval LPSTRCOMMAND AS STRING, BYVAL LPSTRETURnstr as Any, by Val Wretumlen As INTEGER, BYVAL HCALLBACK AS INTEGER) AS Long

'Play the statement required by WAV

Declare function sndplaysound lib "mmsystem.dll" (Byval WF1AGS AS INTEGER) AS Integer

'Detecting the statement required by the sound card

Declare function auxgetnaumdevs lib "mmsystem" () AS Integer

'The global variable declaration used

Global const SND_SYNC = & H0000 'Play WAV for global variables

Global const SND_ASYNC = & - H0001 'Play WAV for global variables

Global const SND_NODEFAULT = & H0002 'Play WAV for global variables

Global const SND_LOOP = & H0008 'Play WAV for global variables

Global const SND_NOSTOP = & - H0010 'Play WAV for global variables

'Next is called these statements

Function auxtest () as boolean

DIM I as integer

i = auxgetnumdevs ()

IF i> 0 THEN

Auxtest = True 'If there is a sound card, return true

EXIT FUNCTION

Else

Auxtest = false 'Returns if the sound card is not detected

EXIT FUNCTION

Else

Auxtest = false 'Returns if the sound card is not detected

EXIT FUNCTION

END IF

END FUNCTION

2. Play the source code of the CD

SUB PlayCD (B AS Integer)

'B is the conversion of the broadcast

DIM A as long

A = McISendstring ("Open CDAUDIO ALIAS CD WAIT", 0 &, 0, 0) 'Initialization Drive

A = McISendstring ("Set CD Time Format TMSF", 0 &, 0, 0)

A = McISendstring ("Play CD from" & Str (b), 0 &, 00) 'Playing the track

End Sub

3. Play AVI source code

SUB Playavi (Avifile As String)

DIM RVAL AS Long

Avifile = "Play" Avifile "fullscreen" 'full screen play AVI file

Rval = McISendstring (Avifile, 0 &, 0,0 &)

End Sub

4. Play the source code for WAV

Sub Playwav (WAVFile AS String)

DIM FLAG AS INTEGER

Dim a as integer

WFLAG = SND_ASYNC OR SND_NODEFAULT

A = SNDPLAYSOUND (WAVFILE, FLAG)

End Sub

The above program is a module I often used when calling multimedia, you only need to call the above module directly in the program.

转载请注明原文地址:https://www.9cbs.com/read-28731.html

New Post(0)