VIDEO.CPP 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  19. //
  20. // Green Video Module
  21. //
  22. // History:
  23. //
  24. // 05/17/95 PPL Started.
  25. // 05/18/95 PPL Complete rewrite using the MCIWnd Class instead of the thousand parameters
  26. // infested mciSendCommand function.
  27. // 05/22/95 PPL Implemented status checking
  28. // 05/23/95 PPL Commented out all the traces within the status checking function for speed.
  29. // 08/10/95 JMI Altered IsPaused, IsStopped, IsPlaying, Destroy, Close, Pause, & Resume to be aware of
  30. // possibility of HWND not being valid.
  31. //
  32. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. // Headers
  35. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  36. #include "Blue.h"
  37. #include "bluewin.h"
  38. #include <winuser.h>
  39. #include <vfw.h>
  40. #include "video.h"
  41. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  42. // External global variables.
  43. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  45. // Module specific constants
  46. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  47. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  48. // Module specific variables
  49. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  50. char ms_szBuf[80]; // Can be used anytime we need a char buffer.
  51. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  52. // Module specific functions
  53. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  54. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  55. // Module specific functions:
  56. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  57. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  58. // Public functions:
  59. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  60. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  61. // Name: CVideo
  62. // Description: This is the default constructor for the class. The responsibility of this function will
  63. // be to initialize any member and/or module static variables.
  64. // Input: none
  65. // Output: none
  66. // History: 05/17/95, PPL, Started coding.
  67. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  68. CVideo::CVideo(void)
  69. {
  70. // Initialize member variables.
  71. Init();
  72. }
  73. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  74. // Name: CVideo
  75. // Description: This is an overloaded constructor. The responsibility of this function will
  76. // be to initialize any member and/or module static variables. Additionaly, the video
  77. // playback device will be opened (created).
  78. // Input: See below for description
  79. // Output: none
  80. // History: 05/17/95, PPL, Started coding.
  81. // 05/18/95, PPL, Rewrote using the MCIWnd Class.
  82. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  83. CVideo::CVideo(char* szFilename, // filename of the video
  84. long x, // left edge of playback window
  85. long y, // top of the playback window
  86. long w, // width of the playback window
  87. long h, // height of the playback window
  88. short sClip) // clipping flag
  89. {
  90. // Call the default constructor.
  91. CVideo();
  92. // Create the playback window and allocate the digital video device.
  93. if (Create() == 0)
  94. {
  95. // Call the create function with the given parameters.
  96. if (Open(szFilename, x, y, w, h, sClip) == 0)
  97. {
  98. // Now that we've successfully created and opened the video file, let's play it.
  99. if (Play() != 0)
  100. {
  101. TRACE("Failed to play the current video.\n");
  102. }
  103. }
  104. else
  105. {
  106. TRACE("Failed to open the requested video file within the overloaded construct!\n");
  107. }
  108. }
  109. else
  110. {
  111. TRACE("Failed to auto create video device within the overload constructor!\n");
  112. }
  113. }
  114. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  115. // Name: ~CVideo
  116. // Description: This is the default destructor for the class. The responsibility of this function will
  117. // be to release the current device, if opened.
  118. // Input: none
  119. // Output: none
  120. // History: 05/17/95, PPL, Started coding.
  121. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  122. CVideo::~CVideo(void)
  123. {
  124. // Destroy an device currently opened.
  125. Destroy();
  126. }
  127. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  128. // Name: Create
  129. // Description: This function creates a window and opens(allocates) the digital video device.
  130. // Input: none.
  131. // Output: 0 if successful, error # otherwise.
  132. // History: 05/17/95, PPL, Started coding.
  133. // 05/18/95, PPL, Rewrote using the MCIWnd Class.
  134. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  135. short CVideo::Create(void)
  136. {
  137. // Let's create the avi video window if one has not already been created.
  138. if (m_lhwnd == 0)
  139. {
  140. m_lhwnd = (long)MCIWndCreate(gsi.hWnd,
  141. gsi.hInstance,
  142. (DWORD)(WS_CHILD |
  143. // WS_EX_TOPMOST |
  144. // WS_THICKFRAME |
  145. // WS_CAPTION |
  146. // WS_BORDER |
  147. // MCIWNDF_NOAUTOSIZEMOVIE |
  148. // MCIWNDF_NOAUTOSIZEWINDOW |
  149. // MCIWNDF_SHOWALL |
  150. MCIWNDF_NOPLAYBAR |
  151. MCIWNDF_NOOPEN |
  152. MCIWNDF_NOMENU |
  153. MCIWNDF_NOERRORDLG),
  154. "avivideo");
  155. if (TraceMCIError("CVideo::Create(MCIWndCreate)") == 0)
  156. {
  157. // Let's subclass the window proc for m_lhwnd.
  158. // First, get and save the window's original proc.
  159. // m_lhwndProc = GetWindowLong((HWND)m_lhwnd, GWL_WNDPROC);
  160. // Now, let's set the window's proc to our's.
  161. // if (SetWindowLong((HWND)m_lhwnd, GWL_WNDPROC, (long)&(this->OurMCIWndProc)) == 0)
  162. // {
  163. // TRACE("Failed to subclass the MCI window's proc to our's.");
  164. // }
  165. return 0;
  166. }
  167. else
  168. return VIDEO_ERR_CREATE;
  169. }
  170. else
  171. return VIDEO_ERR_ALREADY_CREATED;
  172. }
  173. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  174. // Name: Destroy
  175. // Description: This function destroys(releases) the current digital video device and the child window.
  176. // Input: none.
  177. // Output: none.
  178. // History: 05/17/95, PPL, Started coding.
  179. // 05/18/95, PPL, Rewrote using the MCIWnd class.
  180. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  181. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  182. void CVideo::Destroy(void)
  183. {
  184. Close();
  185. // If a window has been created . . .
  186. if (m_lhwnd != NULL)
  187. {
  188. MCIWndDestroy((HWND)m_lhwnd);
  189. }
  190. // Initialize all the member variables.
  191. Init();
  192. }
  193. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  194. // Name: CVideo
  195. // Description: This function will open a video file.
  196. // Input: See below for description
  197. // Output: 0 - Success.
  198. // 1 - Error. (more detailed error codes may be defined later.)
  199. // History: 05/17/95, PPL, Started coding.
  200. // 05/18/95, PPL, Rewrote using MCIWnd Class.
  201. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  202. short CVideo::Open(char* szFilename, // name of the video file
  203. long x, // left edge of the playback window
  204. long y, // top of the playback window
  205. long w, // width of the playback window
  206. long h, // height of the playback window
  207. short sClip) // clipping flag, use following values:
  208. // 0: no clipping, window will be resized to
  209. // actual video's size.
  210. // 1: video will be clipped to the size supplied.
  211. // 2: video will not be clipped, video will be
  212. // stretched/shrinked to the window's size.
  213. {
  214. short sResult;
  215. RECT rect;
  216. long lXdelta;
  217. long lYdelta;
  218. sResult = VIDEO_SUCCESS; // initially no error.
  219. // If no mci window has been created yet, then we need to create one.
  220. if (m_lhwnd == 0)
  221. {
  222. sResult = Create();
  223. }
  224. // Let's issue the actual open command, now that it's safe.
  225. if (sResult == VIDEO_SUCCESS)
  226. {
  227. // Let's open the file first before moving the window to the desired location.
  228. if (MCIWndOpen((HWND)m_lhwnd, szFilename, 0) == 0)
  229. {
  230. // Now that a video file has been properly opened, let's move it and resize if necessary.
  231. // Let's get the current video's rect.
  232. if (MCIWndGetSource((HWND)m_lhwnd, &rect) == 0)
  233. {
  234. // Let's just adjust the location of the window. (find the delta from current)
  235. lXdelta = x - rect.left;
  236. lYdelta = y - rect.top;
  237. rect.left = rect.left + lXdelta;
  238. rect.top = rect.top + lYdelta;
  239. rect.right = rect.right + lXdelta;
  240. rect.bottom = rect.bottom + lYdelta;
  241. // Depending on the mode requested, we might have to adjust the width and height.
  242. switch (sClip)
  243. {
  244. case MODE_STRETCH:
  245. rect.right = rect.left + w;
  246. rect.bottom = rect.top + h;
  247. case MODE_NORMAL:
  248. // Make sure that autowindowsize and automoviesize is turned on.
  249. MCIWndChangeStyles((HWND)m_lhwnd,
  250. MCIWNDF_NOAUTOSIZEWINDOW | MCIWNDF_NOAUTOSIZEMOVIE,
  251. 0);
  252. if (!SetWindowPos((HWND)m_lhwnd,
  253. (HWND)NULL,
  254. rect.left,
  255. rect.top,
  256. rect.right - rect.left,
  257. rect.bottom - rect.top,
  258. SWP_NOACTIVATE|SWP_NOZORDER))
  259. {
  260. TRACE("Failed to move and size window using SetWindowPos()!\n");
  261. sResult = VIDEO_ERR_RESIZE_FAIL;
  262. }
  263. break;
  264. case MODE_CLIP:
  265. // We need to try and clip.
  266. // First, make sure that autowindowsize and automoviesize is turned on.
  267. // We'll set the window to the default movie's size.
  268. MCIWndChangeStyles((HWND)m_lhwnd,
  269. MCIWNDF_NOAUTOSIZEWINDOW | MCIWNDF_NOAUTOSIZEMOVIE,
  270. 0);
  271. if (SetWindowPos((HWND)m_lhwnd,
  272. (HWND)NULL,
  273. rect.left,
  274. rect.top,
  275. rect.right - rect.left,
  276. rect.bottom - rect.top,
  277. SWP_NOACTIVATE))
  278. {
  279. // Now, let's turn of the autowindowsize and antomoviesize and then
  280. // resize to the actual size passed.
  281. MCIWndChangeStyles((HWND)m_lhwnd,
  282. MCIWNDF_NOAUTOSIZEWINDOW | MCIWNDF_NOAUTOSIZEMOVIE,
  283. MCIWNDF_NOAUTOSIZEWINDOW | MCIWNDF_NOAUTOSIZEMOVIE);
  284. if (!SetWindowPos((HWND)m_lhwnd,
  285. (HWND)NULL,
  286. rect.left,
  287. rect.top,
  288. w,
  289. h,
  290. SWP_NOACTIVATE))
  291. {
  292. TRACE("Failed to clip the window!\n");
  293. sResult = VIDEO_ERR_RESIZE_FAIL;
  294. }
  295. }
  296. else
  297. {
  298. TRACE("Failed to move and size window using SetWindowPos()!\n");
  299. sResult = VIDEO_ERR_RESIZE_FAIL;
  300. }
  301. break;
  302. }
  303. }
  304. else
  305. {
  306. TraceMCIError("CVideo::Open(MCIWndGetDest)");
  307. sResult = VIDEO_ERR_GETTING_WRECT;
  308. }
  309. }
  310. else
  311. {
  312. TraceMCIError("CVideo::Open(MCIWndOpen)");
  313. sResult = VIDEO_ERR_OPEN;
  314. }
  315. }
  316. return sResult;
  317. }
  318. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  319. // Name: Close
  320. // Description: This function simulates closing the video file.
  321. // Input: none
  322. // Output: 0 - Success.
  323. // 1 - Error. (more detailed error codes may be defined later.)
  324. // History: 05/17/95, PPL, Started coding.
  325. // 05/18/95, PPL, Rewrote using MCIWnd Class.
  326. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  327. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  328. short CVideo::Close(void)
  329. {
  330. short sRes = VIDEO_ERR_CLOSE;
  331. // If there is a window . . .
  332. if (m_lhwnd != NULL)
  333. {
  334. // No matter what happens here, let's hide the window.
  335. ShowWindow((HWND)m_lhwnd, SW_HIDE);
  336. if (MCIWndClose((HWND)m_lhwnd) == 0)
  337. {
  338. sRes = VIDEO_SUCCESS;
  339. }
  340. else
  341. {
  342. TraceMCIError("CVideo::Close(MCIWndClose)");
  343. }
  344. }
  345. return sRes;
  346. }
  347. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  348. // Name: Play
  349. // Description: This function plays the currently loaded video -- optionally a segment within.
  350. // Input: sMode: see constants in the header file
  351. // lStart: start of the selection
  352. // lEnd: end of the selection
  353. // Output: 0 - Success.
  354. // 1 - Error. (more detailed error codes may be defined later.)
  355. // History: 05/17/95, PPL, Started coding.
  356. // 05/18/95, PPL, Rewrote using MCIWnd Class.
  357. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  358. short CVideo::Play(short sMode, long lStart, long lEnd)
  359. {
  360. long lResult;
  361. if (m_lhwnd)
  362. {
  363. // Let's just show the window.
  364. ShowWindow((HWND)m_lhwnd, SW_SHOW);
  365. switch (sMode)
  366. {
  367. case PLAY_ALL:
  368. lResult = MCIWndPlay((HWND)m_lhwnd);
  369. if (lResult != 0)
  370. TraceMCIError("CVideo::Play(MCIWndPlay)");
  371. break;
  372. case PLAY_SELECTION_TIME:
  373. MCIWndUseTime((HWND)m_lhwnd);
  374. lResult = MCIWndPlayFromTo((HWND)m_lhwnd, lStart, lEnd);
  375. if (lResult != 0)
  376. TraceMCIError("CVideo::PlayStartEnd<TIME>");
  377. break;
  378. case PLAY_SELECTION_FRAME:
  379. MCIWndUseFrames((HWND)m_lhwnd);
  380. lResult = MCIWndPlayFromTo((HWND)m_lhwnd, lStart, lEnd);
  381. if (lResult != 0)
  382. TraceMCIError("CVideo::PlayStartEnd<FRAME>");
  383. break;
  384. }
  385. }
  386. else
  387. lResult = 1;
  388. if (lResult != 0)
  389. return VIDEO_ERR_PLAY;
  390. else
  391. return VIDEO_SUCCESS;
  392. }
  393. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  394. // Name: Pause
  395. // Description: This function pauses the currently playing video.
  396. // Input: none
  397. // Output: 0 - Success.
  398. // 1 - Error. (more detailed error codes may be defined later.)
  399. // History: 05/17/95, PPL, Started coding.
  400. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  401. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  402. short CVideo::Pause(void)
  403. {
  404. short sRes = VIDEO_ERR_PAUSE;
  405. if (m_lhwnd != NULL)
  406. {
  407. if (MCIWndPause((HWND)m_lhwnd) == 0)
  408. {
  409. sRes = VIDEO_SUCCESS;
  410. }
  411. else
  412. {
  413. TraceMCIError("CVideo::Pause(MCIWndPause)");
  414. }
  415. }
  416. return sRes;
  417. }
  418. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  419. // Name: Resume
  420. // Description: This function resumes a previously paused video.
  421. // Input: none
  422. // Output: 0 - Success.
  423. // 1 - Error. (more detailed error codes may be defined later.)
  424. // History: 05/17/95, PPL, Started coding.
  425. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  426. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  427. short CVideo::Resume(void)
  428. {
  429. short sRes = VIDEO_ERR_RESUME;
  430. if (m_lhwnd != NULL)
  431. {
  432. if (MCIWndResume((HWND)m_lhwnd) == 0)
  433. {
  434. sRes = VIDEO_SUCCESS;
  435. }
  436. else
  437. {
  438. TraceMCIError("CVideo::Resume(MCIWndResume)");
  439. }
  440. }
  441. return sRes;
  442. }
  443. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  444. // Name: Stop
  445. // Description: This function stops a video which may current be playing.
  446. // Input: none
  447. // Output: 0 - Success.
  448. // 1 - Error. (more detailed error codes may be defined later.)
  449. // History: 05/17/95, PPL, Started coding.
  450. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  451. short CVideo::Stop(void)
  452. {
  453. long lResult;
  454. lResult = MCIWndStop((HWND)m_lhwnd);
  455. if (lResult != 0)
  456. {
  457. TraceMCIError("CVideo::Stop(MCIWndStop)");
  458. return VIDEO_ERR_STOP;
  459. }
  460. else
  461. return VIDEO_SUCCESS;
  462. }
  463. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  464. // Name: GetFrame
  465. // Description: This function gets the current frame of a video.
  466. // Input: none
  467. // Output: long: current frame number.
  468. // History: 05/17/95, PPL, Started coding.
  469. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  470. long CVideo::GetFrame(void)
  471. {
  472. short sResult;
  473. sResult = VIDEO_SUCCESS;
  474. // First, let's change the format to use frames.
  475. if (MCIWndUseFrames((HWND)m_lhwnd) == 0)
  476. {
  477. return MCIWndGetPosition((HWND)m_lhwnd);
  478. }
  479. else
  480. {
  481. TraceMCIError("CVideo::GetFrame(MCIWndUseFrames)");
  482. sResult = VIDEO_ERR_SET_FRAMES;
  483. }
  484. return sResult;
  485. }
  486. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  487. // Name: GetPosition
  488. // Description: This function gets the current position(milliseconds) of a video.
  489. // Input: none
  490. // Output: long: current position
  491. // History: 05/17/95, PPL, Started coding.
  492. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  493. long CVideo::GetPosition(void)
  494. {
  495. short sResult;
  496. sResult = VIDEO_SUCCESS;
  497. // First, let's change the format to use frames.
  498. if (MCIWndUseTime((HWND)m_lhwnd) == 0)
  499. {
  500. return MCIWndGetPosition((HWND)m_lhwnd);
  501. }
  502. else
  503. {
  504. TraceMCIError("CVideo::GetFrame(MCIWndUseFrames)");
  505. sResult = VIDEO_ERR_SET_TIME;
  506. }
  507. return sResult;
  508. }
  509. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  510. // Name: IsOpened
  511. // Description: This function checks to see if a video is currently opened.
  512. // Input: none
  513. // Output: short: TRUE/FALSE
  514. // History: 05/22/95, PPL, Started coding.
  515. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  516. short CVideo::IsOpened(void)
  517. {
  518. long lResult;
  519. lResult = MCIWndGetMode((HWND)m_lhwnd, ms_szBuf, 80);
  520. // TRACE("Video status: %s\n", ms_szBuf);
  521. TraceMCIError("CVideo::IsOpened(MCIWndGetMode)");
  522. if (lResult == MCI_MODE_OPEN)
  523. {
  524. // A video is currently opened.
  525. return TRUE;
  526. }
  527. else
  528. {
  529. // No video has been opened yet.
  530. return FALSE;
  531. }
  532. }
  533. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  534. // Name: IsPlaying
  535. // Description: This function checks to see if a video is currently playing.
  536. // Input: none
  537. // Output: short: TRUE/FALSE
  538. // History: 05/22/95, PPL, Started coding.
  539. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  540. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  541. short CVideo::IsPlaying(void)
  542. {
  543. short sRes = FALSE;
  544. if (m_lhwnd != NULL)
  545. {
  546. if (MCIWndGetMode((HWND)m_lhwnd, ms_szBuf, 80) == MCI_MODE_PLAY)
  547. {
  548. sRes = TRUE;
  549. }
  550. // TRACE("Video status: %s\n", ms_szBuf);
  551. }
  552. // TraceMCIError("CVideo::IsPlaying(MCIWndGetMode)");
  553. return sRes;
  554. }
  555. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  556. // Name: IsPaused
  557. // Description: This function checks to see if a video is currently paused.
  558. // Input: none
  559. // Output: short: TRUE/FALSE
  560. // History: 05/22/95, PPL, Started coding.
  561. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  562. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  563. short CVideo::IsPaused(void)
  564. {
  565. short sRes = FALSE;
  566. if (m_lhwnd != NULL)
  567. {
  568. if (MCIWndGetMode((HWND)m_lhwnd, ms_szBuf, 80) == MCI_MODE_PAUSE)
  569. {
  570. sRes = TRUE;
  571. }
  572. }
  573. // TRACE("Video status: %s\n", ms_szBuf);
  574. // TraceMCIError("CVideo::IsPaused(MCIWndGetMode)");
  575. return sRes;
  576. }
  577. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  578. // Name: IsStopped
  579. // Description: This function checks to see if a video has been stopped.
  580. // Input: none
  581. // Output: short: TRUE/FALSE
  582. // History: 05/22/95, PPL, Started coding.
  583. // 08/10/95, JMI, Altered to be aware of possibility of HWND not being valid.
  584. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  585. short CVideo::IsStopped(void)
  586. {
  587. short sRes = FALSE;
  588. if (m_lhwnd != NULL)
  589. {
  590. if (MCIWndGetMode((HWND)m_lhwnd, ms_szBuf, 80) == MCI_MODE_STOP)
  591. {
  592. sRes = TRUE;
  593. }
  594. }
  595. // TRACE("Video status: %s\n", ms_szBuf);
  596. // TraceMCIError("CVideo::IsStopped(MCIWndGetMode)");
  597. return sRes;
  598. }
  599. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  600. // Private functions:
  601. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  602. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  603. // Name: Init
  604. // Description: This is private function initializes all the member variables.
  605. // Input: none
  606. // Output: none
  607. // History: 05/17/95, PPL, Started coding.
  608. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  609. void CVideo::Init(void)
  610. {
  611. // To be consistent with the way all our functions return sucess, 0 is success (or TRUE) while all other
  612. // numbers denote error of some sort (or FALSE). All of our 'boolean' shorts are therefore intialized
  613. // to 0.
  614. m_ulDeviceID = 0;
  615. m_lhwnd = 0;
  616. }
  617. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  618. // Name: TraceMCIError
  619. // Description: This function simply put up a trace message containing the string description of
  620. // the current MCIWndError
  621. // Input: szErrOrigin: a description for where the error might have originated.
  622. // Output: long: if 0, then error was not shown
  623. // else, the error number is returned.
  624. // History: 05/17/95, PPL, Started coding.
  625. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  626. long CVideo::TraceMCIError(char* szFunctionName)
  627. {
  628. long lResult;
  629. lResult = MCIWndGetError((HWND)m_lhwnd, ms_szBuf, 80);
  630. if (lResult != 0)
  631. {
  632. TRACE("The following MCIError occurred in %s:\n", szFunctionName);
  633. TRACE("%s\n", ms_szBuf);
  634. }
  635. return lResult;
  636. }