Microsoft KB Archive/282521

= Windows Media Encoder Events Do Not Fire =

Article ID: 282521

Article Last Modified on 5/24/2001

-

APPLIES TO


 * Microsoft Windows Media Encoder 7.0

-



This article was previously published under Q282521



SYMPTOMS
Events do not fire in the Windows Media Encoder.



CAUSE
The Windows Media Encoder message pump thread needs time to initialize.



RESOLUTION
To resolve this problem, do one of the following:   If the application is a console mode application and COM is initialized in Single Threaded Apartment (STA) mode (CoInitialize( NULL ) ), the application must pump messages after it starts encoding. To accomplish this, add the following code after you start the Encoder: hr = pEncoder->Start;

// MsgLoop is necessary to receive messages while (true) {       sec++; if(sec == 30) break; else {               while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) {                   TranslateMessage(&msg); DispatchMessage(&msg); }           Sleep(1000);  // Sleep for 1 sec }   }

pEncoder->Stop; -OR-

  If the application is a Windows-based application and COM is initialized in STA mode (CoInitialize( NULL ) ), add the following function and call before calling PrepareToEncode on the Encoder. This ensures that the Encoder has enough time to initialize. void EncoderInitialization {   //     // Allow encoder init //    int sec = 0 ; MSG msg; while (true) {       sec++; if(sec == 15) break; else {           while ( PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE) ) {               TranslateMessage(&msg); DispatchMessage(&msg); }           Sleep(500); }   } }                        



STATUS
Microsoft has confirmed that this is a problem in Microsoft Windows Media Encoder version 7.0.

This issue has been resolved with Windows Media Encoder 7.1. To upgrade to version 7.1, see the following Microsoft Web site:

Windows Media Homepage

http://www.microsoft.com/windowsmedia



MORE INFORMATION
There are two threads: the main encoder thread and the message pump thread. The message pump thread creates a window and passes the window handle back to the main thread. The window handle is set onto the main thread after Encoder creation. In this case, the main thread is not giving the message pump thread any time to set the window handle.

A known symptom of this problem is that automatic indexing does not occur after the encoding is completed. The suggested changes in the &quot;Resolution&quot; section will resolve this problem.

For additional information, see the Windows Media Encoder SDK.

Additional query words: put_AutoIndex netshow

Keywords: kbbug kbpending KB282521

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.