home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / source / hotspot / viewer / hspplay.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-07  |  3.8 KB  |  123 lines

  1. /**************************************************************************
  2.  *
  3.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6.  *  PURPOSE.
  7.  *
  8.  *  Copyright (c) 1993  Microsoft Corporation.  All Rights Reserved.
  9.  * 
  10.  **************************************************************************/
  11. /*
  12.     hspplay.c:
  13.         hspPlayAVI -- plays an AVI given a window, an AVI file,
  14.             and an INI file
  15. */
  16. #include <windows.h>
  17. #include <mmsystem.h>
  18. #include <digitalv.h>
  19. #include <viewer.h>
  20. #include <string.h>
  21. #include <direct.h>
  22.  
  23. #include "hotspot.h"
  24. #include "mciavi.h"
  25.  
  26. extern char szMovieInfo[];
  27.  
  28. LONG FAR PASCAL _export ICAVIDrawProc(DWORD id, HDRVR hDriver,
  29.     UINT uiMessage, LPARAM lParam1, LPARAM lParam2);
  30.  
  31. /*
  32.     hspPlayAVI -- allocates a movieinfo structure, stores the window
  33.         handle you gave it in the hwndParent entry in the movieinfo,
  34.         and stores the callback you provide in the movieinfo -- these will
  35.         be used by the subclassproc.
  36.  
  37.         It next calls InitHotspots to get a hotspot list, and
  38.         fileOpenMovie which will open the AVI file and create a child
  39.         window (a child of the window that you pass in to this function).
  40.         The window is returned in the movieinfo.  It then subclasses
  41.         the window fileOpenMovie made, by changing the pointer to its
  42.         WindowProc to ours (via SetWindowLong).
  43.  
  44.         It uses SetProp to hook this movieinfo up to both windows.
  45.         The subclassed wndproc will get the movieinfo from the child
  46.         window when a button is clicked, and the parent windowproc will
  47.         get the movieinfo from the parent when Viewer wants to know
  48.         the pane size.
  49.  
  50.         Finally, playMovie is called to start the movie.
  51. */
  52. LONG CALLBACK __export hspPlayAVI(HWND hwnd, LPSTR szAVIFile, 
  53.                     LPSTR szIniFile, FARPROC lpfnhspAVICallback)
  54. {
  55.     HGLOBAL hglb;
  56.     PMOVIEINFO pMovieInfo;
  57.     
  58.     hglb = GlobalAlloc(GHND, sizeof(MOVIEINFO));
  59.     pMovieInfo = (PMOVIEINFO)GlobalLock(hglb);
  60.     
  61.     if (!pMovieInfo)
  62.         return (0L);
  63.     
  64.     pMovieInfo->hwndParent = hwnd;
  65.     pMovieInfo->lpfnhspAVICallback = lpfnhspAVICallback;
  66.     
  67.     if (!hwnd)
  68.         {
  69.         Message("Invalid window specified for playing AVI file.");
  70.         return 0L;
  71.         }
  72.         
  73.     InitHotspots(pMovieInfo, szIniFile);
  74.     
  75.     OutputDebugString("calling fileOpenMovie\n");
  76.     fileOpenMovie(pMovieInfo, szAVIFile);
  77.     GlobalUnlock(hglb);
  78.    
  79.     pMovieInfo->lpfnOldProc = (FARPROC) GetWindowLong (pMovieInfo->hwndMovie, GWL_WNDPROC);
  80.     SetWindowLong (pMovieInfo->hwndMovie, GWL_WNDPROC, (LONG) SbClsProc);
  81.  
  82.     SetProp(pMovieInfo->hwndMovie, (LPSTR) szMovieInfo, hglb);
  83.     SetProp(hwnd, (LPSTR) szMovieInfo, hglb);    
  84.     
  85.     OutputDebugString("calling positionMovie\n");
  86.     positionMovie(pMovieInfo);
  87.     OutputDebugString("calling playMovie\n");
  88.     {
  89.         MCI_DGV_SETVIDEO_PARMS    dgv;
  90.         UINT                    uDevice;
  91.         dgv.dwValue = (DWORD) ICAVIDrawProc;
  92.             //MakeProcInstance((FARPROC) ICAVIDrawProc,hInstApp);
  93.         dgv.dwItem = MCI_AVI_SETVIDEO_DRAW_PROCEDURE;
  94.         uDevice = pMovieInfo->wMCIDeviceID;
  95.         if (uDevice)
  96.         {
  97.             DWORD dw;
  98.                                 
  99.             dw = mciSendCommand(uDevice,
  100.             MCI_SETVIDEO,
  101.             MCI_DGV_SETVIDEO_ITEM | MCI_DGV_SETVIDEO_VALUE,
  102.             (DWORD) (MCI_DGV_SETVIDEO_PARMS FAR *)&dgv);
  103.             OutputDebugString("set draw proc!\n");
  104.             if (dw != 0)
  105.             {
  106.                 MessageBox(GetFocus(),
  107.                     "The currently installed MCIAVI does not "
  108.                     "support the MCI_AVI_SETVIDEO_DRAW_PROCEDURE "
  109.                     "command during play.","MCI Problem",
  110.                     MB_OK | MB_ICONHAND);
  111.             }
  112.         }
  113.         else
  114.         {
  115.             MessageBox(GetFocus(),"movie info has no device id",
  116.                 "real bummer",MB_OK);
  117.         }
  118.         playMovie(pMovieInfo, 1);
  119.     }    
  120.     return (0L);
  121. }
  122.  
  123.