Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
API Call to ring system bell/play .WAV?
Message
 
To
28/08/1999 02:36:20
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00258772
Message ID:
00258889
Views:
113
This sample procedures don't have any error control,
they only provide the basic.
* Play a wave file using Microsoft Multimedia Control
PROCEDURE PlayWavCtrl
   LParam pcWavfile

   Local loMMControl
   loMMControl = CreateObject('MCI.MMControl')

   loMMControl.DeviceType = 'WaveAudio'
   loMMControl.Filename = FullPath(pcWavfile)
   loMMControl.command='Open'
   loMMControl.Wait = .t.
   loMMControl.command='Play'
   loMMControl.command='Close'

   Release loMMControl
ENDPROC

* Play a wave file using the Multimedia API
PROCEDURE PlayWavAPI
    LParam pcWavfile
    DECLARE INTEGER mciSendString IN WINMM ;
            STRING sendstr, INTEGER retstr, ;
            INTEGER szret, INTEGER callback

    mciSendString("open "+Fullpath(pcWavfile)+ ;
                 " type waveaudio alias mmwav", 0, 0, 0)
    mciSendString("play mmwav wait", 0, 0, 0)
    mciSendString("close mmwav", 0, 0, 0)
ENDPROC
>I need to be able to play .WAV files in my VFP 5 app. The combination of SET BELL TO "MySound.WAV", 0 and ??CHR(7) works perfectly at the VFP command window, but not within my app (based on Visual FoxExpress 5). No errors come up, the sound simply doesn't play.
>
>According to earlier threads, the problem may be in trying to use ??CHR(7) when a control incapable of accepting streaming output has the focus. As a workaround, Mark McCasland kindly posted an API call that reliably rings the bell. However, its "repertoire" seems to be limited to the Windows system sounds (e.g. DING.WAV), and it ignores the current VFP SET BELL setting.
>
>Is there another API call that could accept a .WAV file to play as a parameters? Or, can anyone think of a workaround? I think I'd prefer the API route if at all possible, because the .WAV files are called from a form method that is in turn called by a timer TimerEvent(), so I can't ever be sure which control will have the focus.

Just an opinion... Not a fact.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform