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