home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac_os2 / pmaud11.zip / MCIPLAY.C < prev    next >
C/C++ Source or Header  |  1996-04-05  |  2KB  |  60 lines

  1. /*
  2.  * These routines setup and playback audiofiles.
  3.  *
  4.  *  Written by Ryan C. Gordon, 1996. Feel free to use this code, but please
  5.  *   drop me an email (mailto:warped42@ix.netcom.com), so I can see if these
  6.  *   are doing anyone any good.
  7.  */
  8.  
  9. #define INCL_OS2MM
  10. #include <os2.h>
  11. #include <os2me.h>
  12. #include "mciplay.h"
  13.  
  14. void mciplay(MCIPLAYARGS *micp)
  15. /*
  16.  * The mainline. Accepts multiple filenames on the command line, and plays
  17.  *   the files in the specified order.
  18.  *
  19.  *    params : *pmaudargs == argument structure.
  20.  *   returns : errorlevel 0 if successfull, errorlevel 1 otherwise.
  21.  */
  22. {
  23.     MCI_OPEN_PARMS    mop;        /* for MCI_OPEN message.      */
  24.     MCI_PLAY_PARMS    mpp;        /* for MCI_PLAY message.      */
  25.     MCI_GENERIC_PARMS mgp;        /* for MCI_CLOSE message.     */
  26.     int looper;                    /* for-loop control variable. */
  27.  
  28.     for (looper = 1; looper < micp->ARGC ; looper++)
  29.     {
  30.         /* Open audio device (the sound card) */
  31.         mop.hwndCallback = (HWND) NULL;
  32.         mop.usDeviceID = (USHORT) NULL;
  33.         mop.pszDeviceType = (PSZ) NULL;
  34.         mop.pszElementName = (PSZ) micp->ARGV[looper];
  35.  
  36.         if (mciSendCommand(0,
  37.                            MCI_OPEN,
  38.                            MCI_WAIT | MCI_OPEN_SHAREABLE | MCI_OPEN_ELEMENT,
  39.                            (PVOID) &mop,
  40.                            0) == MCIERR_SUCCESS)
  41.         {
  42.  
  43.             /* Play the sound.  */
  44.             mpp.hwndCallback = (HWND) NULL;
  45.             mpp.ulFrom = 0;
  46.             mpp.ulTo = 0;
  47.             mciSendCommand(mop.usDeviceID, MCI_PLAY, MCI_WAIT, (PVOID)&mpp, 0);
  48.     
  49.             /* Close the file and device. */
  50.             mgp.hwndCallback = (HWND) NULL;
  51.             mciSendCommand(mop.usDeviceID, MCI_CLOSE, MCI_WAIT,
  52.                           (PVOID) &mgp, 0);
  53.         } /* if */
  54.  
  55.     } /* for */
  56.  
  57. } /* mciplay */
  58.  
  59. /* end of mciplay.c */
  60.