home *** CD-ROM | disk | FTP | other *** search
/ Chip Multimedia 1993 January / chip_mm_1.iso / standard / 08 / video.c next >
Encoding:
C/C++ Source or Header  |  1993-10-01  |  3.3 KB  |  129 lines

  1. #include <WINDOWS.H>
  2. #include <MMSYSTEM.H>
  3. #include <DIGITALV.H>
  4. #include "VIDEO.H"
  5.  
  6. int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  7. {
  8.     // RudimentΣres Hauptprogramm
  9.     
  10.     FARPROC Procedure = MakeProcInstance ((FARPROC) DialogBoxProc, hInstance);
  11.     DialogBox (hInstance, "DialogBox", NULL, (DLGPROC) Procedure);
  12.     FreeProcInstance (Procedure);
  13.     return (0);
  14. }
  15.  
  16.  
  17. BOOL FAR PASCAL DialogBoxProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  18. {
  19.     // Dialogfunktion zur Verwaltung der Buttons
  20.     
  21.     static BOOL FileOpen    = FALSE;
  22.     static WORD VideoDevice = 0;
  23.     
  24.     switch (message)
  25.     {
  26.         case WM_COMMAND:
  27.             switch (wParam)
  28.             {
  29.                 case ID_BUTTON_OPEN:
  30.                     if (! FileOpen)
  31.                         if (VideoDevice = OpenVideo ("D:\\DEMO.AVI", hDlg))
  32.                             FileOpen = TRUE;
  33.                     break;
  34.                 
  35.                 case ID_BUTTON_PLAY:
  36.                     PlayVideo (VideoDevice, hDlg);
  37.                     break;
  38.                 
  39.                 case ID_BUTTON_STOP:
  40.                     StopVideo (VideoDevice);
  41.                     break;
  42.                     
  43.                 case ID_BUTTON_CLOSE:
  44.                     CloseVideo (VideoDevice);
  45.                     FileOpen = FALSE;
  46.                     break;
  47.                     
  48.                 case ID_BUTTON_END:
  49.                     EndDialog (hDlg, TRUE);
  50.                     break;
  51.             }
  52.             
  53.             break;
  54.             
  55.         case MM_MCINOTIFY: // Abspielen ist beendet, Video zurⁿcksetzen
  56.             RewindVideo (VideoDevice);
  57.             break;
  58.     }
  59.     
  60.     return (FALSE);
  61. }
  62.     
  63.     
  64. WORD OpenVideo (char * Filename, HWND ParentWindow)
  65. {
  66.     DWORD              OpenFlags;
  67.     MCI_DGV_OPEN_PARMS OpenParms;
  68.     
  69.     // 1.Ausfⁿllen der speziellen Struktur fⁿr ein MCI-Kommando...
  70.     OpenParms.lpstrElementName = (LPSTR) Filename;
  71.     OpenParms.dwStyle          = WS_VISIBLE | WS_THICKFRAME;
  72.     OpenParms.hWndParent       = ParentWindow;
  73.     
  74.     // 2.Setzen ben÷tigter Flags...
  75.     OpenFlags = MCI_OPEN_ELEMENT | MCI_DGV_OPEN_WS | MCI_DGV_OPEN_PARENT;
  76.     
  77.     if (! mciSendCommand (0, MCI_OPEN, OpenFlags, (DWORD) (LPVOID) & OpenParms))
  78.     {
  79.         // 4. Je nach Kommando Rⁿckgabewerte in der Struktur interpretieren
  80.         return (OpenParms.wDeviceID);
  81.     }
  82.     
  83.     else // Fehler
  84.     {
  85.         return (0);
  86.     } // end of else
  87. }
  88.  
  89.  
  90. DWORD CloseVideo (WORD Device)
  91. {
  92.     MCI_GENERIC_PARMS GenericParms;
  93.     
  94.     return (mciSendCommand (Device, MCI_CLOSE, 0L, (DWORD) (LPVOID) & GenericParms));
  95. }
  96.  
  97.  
  98. DWORD PlayVideo (WORD Device, HWND Window)
  99. {
  100.     MCI_DGV_PLAY_PARMS PlayInfo;
  101.     
  102.     PlayInfo.dwCallback = (DWORD) Window;
  103.     
  104.     return (mciSendCommand (Device, MCI_PLAY, MCI_NOTIFY, (DWORD) (LPVOID) & PlayInfo));
  105.  
  106.  
  107. DWORD StopVideo (WORD Device)
  108. {
  109.     MCI_DGV_STOP_PARMS StopInfo;
  110.     
  111.     return (mciSendCommand (Device, MCI_STOP, 0L, (DWORD) (LPVOID) & StopInfo));
  112. }
  113.  
  114.  
  115. DWORD RewindVideo (WORD Device)
  116. {
  117.     MCI_SEEK_PARMS SeekInfo;
  118.     
  119.     return (mciSendCommand (Device, MCI_SEEK, MCI_SEEK_TO_START, (DWORD) (LPVOID) & SeekInfo));
  120. }
  121.  
  122.  
  123.  
  124.  
  125.  
  126.                     
  127.     
  128.