home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15184 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.2 KB

  1. Path: sparky!uunet!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!sun-barr!ames!data.nas.nasa.gov!taligent!apple!apple!NewsWatcher!user
  2. From: REEKES@applelink.apple.com (Jim Reekes)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Sound Loop in a with a Modal Dialog?
  5. Message-ID: <REEKES-080992142744@90.10.20.67>
  6. Date: 8 Sep 92 21:28:14 GMT
  7. References: <1992Sep3.145524.8874@utkux1.utk.edu>
  8. Sender: usenet@Apple.COM
  9. Followup-To: comp.sys.mac.programmer
  10. Organization: Apple Computer, Inc.
  11. Lines: 41
  12.  
  13. In article <1992Sep3.145524.8874@utkux1.utk.edu>, danny@utkux1.utk.edu
  14. (Danny W. McCampbell) wrote:
  15. > Hi.  I want to play a sound continuously while a modal dialog is 
  16. > present on the screen.  I have successfully go the loop to work
  17. > without the modal dialog statement but the loop is only executed
  18. > twice when I call modal dialog.  Here is  some sample code:
  19. > dialogtrue := true;
  20. > while dialogtrue do
  21. > begin
  22. >   FlushSndChannel(mySndChan);
  23. >   if SoundisStopped(mySndChan) then
  24. >   begin
  25. >     PlaytheSound(mySndChan);
  26. >   end;
  27. >   ModalDialog(nil, itemHit);            {Call Modal Dialog until the user clicks in the dialog}
  28. >   if itemHit = 1 then
  29. >     dialogtrue := false;
  30. > end;
  31. > StoptheSound(mySndChan);
  32. > DisposDialog(AboutDialog);                {Dispose of the Dialog}
  33. > The sound plays only twice then stops playing.  Any ideas how I can
  34. > do this successfully?  Thanks in advance.
  35.  
  36. The approach I would take is to start the sound, then call ModalDialog.
  37. You need to use the callBackCmd and a CallBackProc.  You first play the
  38. sound (ie. bufferCmd) then issue the callBackCmd.  When the sound ends
  39. your CallBackProc is called.  This will call SndDoCommand with another
  40. bufferCmd to start the sound again.
  41.  
  42. The approach you have outlined above will always be starting and stopping
  43. the sound for events caused by the user.
  44.  
  45. -----------------------------------------------------------------------
  46. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  47.                              |          Sound Manager Expert
  48. Apple Computer, Inc.         | RAll opinions expressed are mine, and do
  49. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  50. Cupertino, CA 95014          |       employer, Apple Computer Inc.S
  51.