Board index » delphi » Registering & Playing Registered Sounds in Windows

Registering & Playing Registered Sounds in Windows

I want to Register (if that is the right term) a Sound Event in Win '95
(so that the user can specify the sound file to be played in the Control
Panel). Then I want to play that sound from my Delphi Application.

How do I go about doing this???
Sample Code???

Thanks,

Matthew

 

Re:Registering & Playing Registered Sounds in Windows


Matthew McDermott <matt...@lightspeed.net> wrote in article
<32EBB09B.3...@lightspeed.net>...

Quote
> I want to Register (if that is the right term) a Sound Event in Win '95
> (so that the user can specify the sound file to be played in the Control
> Panel). Then I want to play that sound from my Delphi Application.

Matthew,

I use the following code to play various wavefiles in my application.  Be
sure and add the "MMsystem" unit to your application to use the
sndPlaySound api function.

The AudioMode variable refers to the following:
Snd_sync    -  Play sound now and do not interrupt it
Snd_async  -  Play sound now, but terminate any currently playing sound.

other options in MMSYSTEM doucmentation

++++++++++++++++++

The routine is passed two parameters, One the name of the WAV file to play
the other is how to play it.

{ ** This routine builds the complete path and plays the wave file
     specified by the calling routine ** }

procedure PlayAudio(var wavefile: Pchar ; AudioMode: word ) ;

Var
  WavePtr : Pchar   ;  { Build file name string here }

Begin
      GetMem(WavePtr,80)               ; { Max length of path is 79 }
      WavePtr[0] := char(byte(0))       ; { Null out the new string }
      if AudioMute then
        StrCat(WavePtr,'WAV\NoSound.wav') { This is very short wav file
which plays no sound }
      else
        Begin
         StrCat(WavePtr,'WAV\');{ Path to files }
         StrCat(WavePtr,WaveFile)         ;{ Actual wave file appended }
        end;
      sndPlaySound(WavePtr,AudioMode)  ; { call WIN API MM routine }
      Freemem(WavePtr,80)              ; { Release the memory }
End;

Hope this helps you.
Mark G. Zeringue
m...@ix.netcom.com

Other Threads