void Video::play_until_end( char *fileName, HINSTANCE hInstance, DWORD t) { HANDLE ahObjects[1]; // Handles that need to be waited on const int cObjects = 1; // Number of objects that we have if(!init_success) return; hwnd = NULL; #ifdef CREATE_DUMMY_WINDOW create_dummy_window(hInstance); #endif play(fileName, t); while( state == PLAYING ) { if( (ahObjects[ 0 ] = hGraphNotifyEvent) == NULL) { state = STOPPED; break; } DWORD Result = MsgWaitForMultipleObjects( cObjects, ahObjects, FALSE, INFINITE, QS_ALLINPUT); // Have we received an event notification if( Result >= WAIT_OBJECT_0 && Result < (WAIT_OBJECT_0 + cObjects) ) { if( Result == WAIT_OBJECT_0 ) on_graph_notify(); } else if( Result == WAIT_OBJECT_0 + cObjects ) { if( hwnd ) { while (ProcessNextEvent() == 1) {}; // process everything we can } } else { // other event to wait ... } } if( hwnd ) { DestroyWindow(hwnd); } hwnd = NULL; // after video end, go back to the game if( sys.init_flag ) { ShowMainWindow(); FocusMainWindow(); } }
void Video::play_until_end( char *fileName, HINSTANCE hInstance, DWORD t) { HANDLE ahObjects[1]; // Handles that need to be waited on const int cObjects = 1; // Number of objects that we have if(!init_success) return; hwnd = NULL; #ifdef CREATE_DUMMY_WINDOW create_dummy_window(hInstance); #endif play(fileName, t); while( state == PLAYING ) { if( (ahObjects[ 0 ] = hGraphNotifyEvent) == NULL) { state = STOPPED; break; } DWORD Result = MsgWaitForMultipleObjects( cObjects, ahObjects, 0, INFINITE, QS_ALLINPUT); // Have we received an event notification if( Result >= WAIT_OBJECT_0 && Result < (WAIT_OBJECT_0 + cObjects) ) { if( Result == WAIT_OBJECT_0 ) on_graph_notify(); } else if( Result == WAIT_OBJECT_0 + cObjects ) { if( hwnd ) { // message in the message queue MSG msg; while( PeekMessage(&msg, hwnd, 0, ~0UL, PM_NOREMOVE) ) { if( !GetMessage(&msg, hwnd, 0, ~0UL) ) break; TranslateMessage(&msg); DispatchMessage(&msg); } } } else { // other event to wait ... } } if( hwnd ) { PostMessage( hwnd, WM_CLOSE, 0, 0 ); //handle outstanding message MSG msg; while( GetMessage(&msg, hwnd, 0, ~0UL) ) { TranslateMessage(&msg); DispatchMessage(&msg); } } hwnd = NULL; }