Windows Media Player 11 SDK Rendering in a Separate Window (deprecated)
Previous | Next |
Rendering in a Separate Window (deprecated)
This page documents a feature that may be unavailable in future versions of Windows Media Player and the Windows Media Player SDK.
The sample rendering plug-in created by the Windows Media Player Plug-in Wizard is designed to render in a window that is hosted in the Windows Media Player user interface (UI), specifically the Now Playing tab. However, you may create digital media content containing a custom stream of data that should be rendered in addition to video content. Windows Media Player does not provide a rendering region in its UI while it is rendering video, so the solution is to render the custom data in a separate window.
You can make some simple changes to the sample rendering plug-in code to enable you to render in a separate window. This section describes how to change the code to create a separate window that has a title bar, a text title, a maximize button, a minimize button, and a close button. The user can resize the window, move it to a different location on the desktop, and close the window. These are the normal behaviors that a user expects from a window; you can create your window to behave any way you choose.
This section assumes that you have already modified the sample plug-in implementation to render your content. Following the steps in this section will not create a plug-in that renders content from the sample digital media file rendering.asf provided with this SDK, because it does not contain a video stream. Do not use the sample file GUID for your media type in the code you create for this section.
Warning Attempting to play rendering.asf using the plug-in you create in this section may yield unexpected results.
To modify the sample plug-in code, follow these steps:
- Change the code that creates the rendering window. Set the window style to WS_OVERLAPPEDWINDOW, which provides all the features required. Also, add code to set the window title. Modify the code that creates the window in CreateRenderWin to match the following example:
// Create the plug-in window. HWND hWnd = Create( GetDesktopWindow(), m_rctSrc, NULL, WS_OVERLAPPEDWINDOW );
if ( NULL == hWnd ) { return E_HANDLE; }
// Set the window title. SetWindowText( _T("Rendering Plug-in Sample") );
ShowWindow(SW_HIDE);
return S_OK;
- Add code to paint the window background white when the user resizes the window. The sample plug-in depends on the StretchBlt function to fill the entire region supplied by Windows Media Player with the bitmap the plug-in creates. Your separate window will only render the bitmap at its default size, so you must repaint the window background in response to the user's actions. Add the following code to OnPaint just after the variable declarations at the beginning of the function:
// Add painting code to paint background white. RECT rc; // Represents the window client area.
// Get the window RECT. GetClientRect( &rc );
Add the following code just after the call to **BeginPaint**:
<pre class="syntax" IsFakePre="true" xmlns="https://www.w3.org/1999/xhtml">
// Fill the window with a white brush. FillRect( hDC, &rc, WHITE_BRUSH );
Change the code in ProcessInput that ensures the window is visible. Modify the code to match the following example:
if ( m_hWnd && !IsWindowVisible() && !m_bFullScreen ) { // Under these circumstances, be sure // that the plug-in window is visible. ShowWindow( SW_SHOW ); }
Prevent the window from forwarding mouse and keyboard messages to Windows Media Player. Otherwise, the window will not respond to the user's actions. Remove the following lines of code from the ATL message map in the project's main header file:
// Remove these. MESSAGE_RANGE_HANDLER(WM_KEYDOWN, WM_KEYUP, OnPluginWindowMessage) MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnPluginWindowMessage) MESSAGE_RANGE_HANDLER(WM_MOUSEMOVE, WM_MBUTTONDBLCLK, OnPluginWindowMessage) MESSAGE_RANGE_HANDLER(WM_NCMOUSEMOVE, WM_NCMBUTTONDBLCLK, OnPluginWindowMessage)
You can remove the implementations of the following interfaces.
- IWMPNodeRealEstate
- IWMPNodeWindowed
- IWMPNodeWindowless
You should remove the code in AdviseWMPServices that retrieves pointers to the corresponding host interfaces. You can also remove the implementation of OnPluginWindowMessage, which is the function that normally receives mouse and keyboard messages from the ATL message map.
See Also
Previous | Next |