The topics in this section are related to applications running outside of Windows Media Center. Topic Description Browsing to a Specific Page Describes how third-party applications can browse to specific pages in the Windows Media Center UI. Using Remote Control Input Outside of Windows Media Center Describes how applications outside of Windows Media Center can use the Windows Media Center remote control. Handling the Play and Pause Commands Describes how applications outside of Windows Media Center can handle commands from the Play and Pause buttons on the remote control in combination with Play/Pause commands from the keyboard. Allowing Applications to Handle AutoPlay Events Describes the AutoPlay feature, which automatically starts playing removable media content when the user inserts it or attaches it to the computer, and how to register third-party applications to respond to the AutoPlay events. CD and DVD Content Burning Describes how to create Windows Media Center applications that provide CD and DVD recording capabilities to exchange file and disc information with Windows Media Center, and to retrieve lists of user-selected files for recording onto a CD or DVD.
See Also
Windows Media Center exposes a way for third-party applications to launch Windows Media Center and browse to a specific set of pages. This process works regardless of whether the Windows Media Center user interface (UI) is currently running. This process also brings the Windows Media Center UI to the foreground. This process is the only supported mechanism of browsing to the Windows Media Center UI from a third-party stand-alone application, and was first made available in Microsoft Windows XP Media Center Edition 2004. To browse to the Windows Media Center UI, the third-party application must do the following:
- Call the Win32 FindWindow API, passing "Media Center Tray Applet" for the class name and NULL for the window name.
- If the FindWindow API returns NULL, display an error and exit.
- Call the Win32 RegisterWindowMessage API passing "Media Center Navigate To Page", and then save the result.
- Call the Win32 SendMessageTimeout API passing the window returned in step 2, the message registered in step 3, and the appropriate values for the WPARAM and LPARAM parameters from the tables below. WPARAM values for browsing: Windows Media Center page WPARAM value Windows Media Center Start Menu WPARAM = 0 Live TV WPARAM = 1 TV Guide WPARAM = 2 My TV WPARAM = 3 Recorded TV WPARAM = 4 My Music WPARAM = 5 My Photos WPARAM = 6 Schedule Recordings WPARAM = 7 My Videos WPARAM = 8 Radio WPARAM = 9 Online Spotlight (only for Update Rollup 2 for Windows XP Media Center Edition 2005 and later) WPARAM = 12 Extensibility application (only for Update Rollup 2 for Windows XP Media Center Edition 2005 and later) WPARAM = 13
LPARAM values for browsing: Startup state LPARAM value Start Windows Media Center in the last used state (full screen or windowed) LPARAM = 0 Start Windows Media Center full screen LPARAM = 1
New values may be added in future versions of Windows Media Center. 5. If the SendMessage API returns a non-zero value, the browse failed. See Also • Managing Navigation
This topic describes the Windows commands generated by the remote control device driver and how to retrieve them so that your application can respond appropriately to input. The following table shows the associated messages and keyboard equivalents for the compulsory and optional buttons on the remote control. Button Message Command Keyboard equivalent
- To be determined — SHIFT+8 Back WM_APPCOMMAND APPCOMMAND_BROWSER_BACK BACKSPACE Chan/Page Down WM_APPCOMMAND APPCOMMAND_MEDIA_CHANNEL_DOWN MINUS SIGN (-) CTRL+MINUS SIGN PAGE DOWN Chan/Page Up WM_APPCOMMAND APPCOMMAND_MEDIA_CHANNEL_UP PLUS SIGN (+) CTRL+SHIFT+PLUS SIGN PAGE UP Clear WM_KEYDOWN VK_ESCAPE ESC Details WM_INPUT — — Down WM_KEYDOWN VK_DOWN DOWN ARROW DVD Angle WM_INPUT — — DVD Audio WM_INPUT — — DVD Menu WM_INPUT — — DVD Subtitle WM_INPUT — — eHome Not for use by applications. — — Enter VK_RETURN — ENTER Fwd WM_APPCOMMAND APPCOMMAND_MEDIA_FASTFORWARD CTRL+SHIFT+F Guide WM_INPUT — — Left WM_KEYDOWN VK_LEFT LEFT ARROW Mute WM_APPCOMMAND APPCOMMAND_VOLUME_MUTE F8 My Music WM_INPUT — — My Pictures WM_INPUT — — Recorded TV WM_INPUT — — My TV WM_INPUT — — My Videos WM_INPUT — — Number keys WM_KEYDOWN VK_0 to VK_9 0 to 9 OEM1 WM_INPUT — — OEM2 WM_INPUT — — OK WM_KEYDOWN VK_RETURN ENTER SPACEBAR Pause WM_APPCOMMAND APPCOMMAND_MEDIA_PAUSE CTRL+P Play WM_APPCOMMAND APPCOMMAND_MEDIA_PLAY CTRL+SHIFT+P Record WM_APPCOMMAND APPCOMMAND_MEDIA_RECORD CTRL+R Replay WM_APPCOMMAND APPCOMMAND_MEDIA_PREVIOUSTRACK CTRL+B Rewind WM_APPCOMMAND APPCOMMAND_MEDIA_REWIND — Right WM_KEYDOWN VK_RIGHT RIGHT ARROW Skip WM_APPCOMMAND APPCOMMAND_MEDIA_NEXTTRACK CTRL+F Standby WM_INPUT — — Stop WM_APPCOMMAND APPCOMMAND_MEDIA_STOP CTRL+S Up WM_KEYDOWN VK_UP UP ARROW TV/Jump WM_INPUT — — Vol Down WM_APPCOMMAND APPCOMMAND_VOLUME_DOWN F9 Vol Up WM_APPCOMMAND APPCOMMAND_VOLUME_UP F10
Buttons that generate WM_INPUT messages are defined according to the Human Interface Device (HID) specification. The following table shows the HID mapping of these buttons. Button Usage page Page name Collection usage ID Button usage ID Details 0x0C Consumer controls 0x01 0x209 (AC properties) DVD Angle 0xFFBC Vendor-defined 0x88 0x4B DVD Audio 0xFFBC Vendor-defined 0x88 0x4C DVD Menu 0xFFBC Vendor-defined 0x88 0x24 DVD Subtitle 0xFFBC Vendor-defined 0x88 0x4D Guide 0x0C Consumer controls 0x01 0x8D (AC Program Guide) My Music 0xFFBC Vendor-defined 0x88 0x47 My Pictures 0xFFBC Vendor-defined 0x88 0x49 My TV 0xFFBC Vendor-defined 0x88 0x46 My Videos 0xFFBC Vendor-defined 0x88 0x4A OEM1 0xFFBC Vendor-defined 0x88 0x80 OEM2 0xFFBC Vendor-defined 0x88 0x81 Recorded TV 0xFFBC Vendor-defined 0x88 0x48 Standby 0x01 Generic desktop 0x80 0x82 TV/Jump 0xFFBC Vendor-defined 0x88 0x25
To process WM_INPUT messages, the application must first register the devices from which it receives data. You can do this by using the Win32® function RegisterRawInputDevices. Each RAWINPUTDEVICE structure passed to this function specifies one usage page and usage. The following example C++ code registers the device to receive input from the controls defined on the vendor-defined usage page that have a usage of 0x88: RAWINPUTDEVICE Rid[1];
Rid[0].usUsagePage = 0xFFBC; Rid[0].usUsage = 0x88; Rid[0].dwFlags = 0;
if (RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])) == FALSE) { ErrorExit(); // Add error-handling code here. }
To identify the event that triggered a WM_INPUT message, your application must parse the data passed to the window procedure as the lParam parameter. If you are using the Microsoft .NET Framework, you must implement the WndProc method to retrieve messages. The WndProc method is a member of the NativeWindow class found in the System.Windows.Forms namespace. The overridden method is called each time a new message is placed in the form's message queue. Before returning, the method must call the base WndProc method to ensure that unprocessed messages are handled properly. The following C# code shows how to use the WndProc method to retrieve WM_KEYDOWN messages: using System.Windows.Forms; . . . class Form1Window : NativeWindow { private const int WM_KEYDOWN = 0x0100; private int iChar; public Form1 form;
protected override void WndProc(ref Message message) { // Handle the navigation and numeric buttons.
if (message.Msg == WM_KEYDOWN)
{
iChar = message.WParam.ToInt32();
switch(iChar)
{
case (int)Keys.D0:
// Handle 0 key here.
break;
// Insert more cases here.
. . . } // End switch. } // End key messages. base.WndProc(ref message); } // End WndProc } // End class.
In the initialization code for the main form, you must create an instance of the Form1Window class and assign the main form to it, as follows: public Form1() { InitializeComponent(); Form1Window win = new Form1Window(); win.form = this; win.AssignHandle(this.Handle); }
To learn more about Human Interface Device (HID) and the structure of HID data, see the USB home page (http://www.usb.org). See Also • Managing Navigation • Understanding Mouse, Keyboard, and Remote Control Input
The Play and Pause buttons on the remote control generate separate commands, APPCOMMAND_MEDIA_PLAY and APPCOMMAND_MEDIA_PAUSE, respectively. In addition, some keyboards use a single button to switch between the playing and paused states, generating an APPCOMMAND_MEDIA_PLAY_PAUSE message. Applications should be able to process messages from either the remote control or the keyboard, while keeping track of the current playback state and responding appropriately. The following table shows the playback state, the keyboard or remote control command, and the recommended action an application should take in response to these messages. State Command Action Stopped APPCOMMAND_MEDIA_PLAY Play Stopped APPCOMMAND_MEDIA_PAUSE Nothing Stopped APPCOMMAND_MEDIA_PLAY_PAUSE Play Playing APPCOMMAND_MEDIA_PLAY Nothing Playing APPCOMMAND_MEDIA_PAUSE Pause Playing APPCOMMAND_MEDIA_PLAY_PAUSE Pause Paused APPCOMMAND_MEDIA_PLAY Play Paused APPCOMMAND_MEDIA_PAUSE Nothing Paused APPCOMMAND_MEDIA_PLAY_PAUSE Play
See Also • Managing Navigation • Understanding Mouse, Keyboard, and Remote Control Input
Windows Media Center includes a feature called AutoPlay that automatically starts playing removable media content when the user inserts it or attaches it to the computer. When Windows Media Center detects a type of removable media content that it recognizes, it displays a list of applications that can handle the media type, prompting the user to choose which application will play the content. (Note that Windows Media Center responds to AutoPlay events only when it is maximized.) As an OEM, you can provide applications that Windows Media Center can invoke to service AutoPlay events. The applications must be registered with Windows Media Center as AutoPlay event handlers, as described in the following topics: Topic Description Registering AutoPlay Event Handlers Provides the step-by-step procedure for registering applications that handle Windows Media Center AutoPlay events. Identifying the Drive Containing the Removable Media Explains how hosted HTML applications retrieve the drive letter for AutoPlay events that occur as a result of the user inserting media into a disk drive. Registering AutoPlay Event Handlers for HD DVD and Blu-ray Disc Describes how to register HD DVD or Blu-ray Disc playback applications to handle the AutoPlay events that occur when the user inserts or connects removable media to the Windows Media Center PC.
See Also • Developing Applications for Windows Media Center • Playing Media
The system generates an AutoPlay event whenever the user inserts or attaches removable media to the computer while Windows Media Center is maximized. Each type of removable media causes a different AutoPlay event. When an AutoPlay event occurs, Windows Media Center checks the registry to find a handler for that event. As an OEM, you must register handlers for each type of AutoPlay event that your application handles. To do so, use the following steps:
- Create the following keys in the system registry: HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\MEDIA CENTER\AutoPlayHandlers
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\MEDIA CENTER\AutoPlayHandlers\EventHandlers
- Under the EventHandlers key, list the media events for which you wish to receive notifications by creating a key specifying the event: HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\MEDIA CENTER\AutoPlayHandlers\EventHandlers\EventHandler
Here, EventHandler is one or more of the following key names, based on the type of media detected: Media Detected EventHandler key name Redbook audio CD PlayCDAudioOnArrival video DVD PlayDVDMovieOnArrival VCD PlayVCDMovieOnArrival SVCD PlaySVCDMovieOnArrival Video files (removable media) PlayVideoFilesOnArrival Music files (removable media) PlayMusicFilesOnArrival Digital (still) camera CameraOnArrival Sync device TransferOnArrival Photos ViewPictureFilesOnArrival
-
Under each EventHandler key, create one string value for each application that handles the event. The string values have no associated data.
-
Next, specify the AutoPlay handling application (as a path to an .MCL file) that Windows Media Center should launch for each registered AutoPlay event handler specified in Steps 1 through 3. Start by creating the following key in the system registry: HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\MEDIA CENTER\AutoPlayHandlers\Handlers
-
Under the Handlers key, create one subkey for each string value specified in Step 3: HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENT VERSION\MEDIA CENTER\AutoPlayHandlers\Handlers\HandlerKeyName
where HandlerKeyName is the same as a string value created in Step 3. 6. Under each HandlerKeyName key, create the following strings: Value Type Data Action REG_SZ Display name for the application (this name must be short enough to be displayed in the available space). InvokeMCL REG_SZ Fully-qualified path to the .MCL file that Windows Media Center should process when the AutoPlay event occurs.
See Also • Allowing Applications to Handle AutoPlay Events
When Windows Media Center invokes an AutoPlay event handler as a result of a drive-related event (for example, the user inserted a DVD), the application that handles the event should query the MediaCenter.Context property for the drive letter. Because only Windows Media Center applications have access to Windows Media Center's object model, an executable run as an AutoPlay handler does not have access to the Context property. See Also • Allowing Applications to Handle AutoPlay Events
Windows Media Center supports HD DVD and Blu-ray Disc playback, as follows: • When Windows Media Center is running full screen, Windows Media Center can start a third-party playback application when a HD DVD or Blu-ray Disc disc is inserted into the DVD drive. If Windows Media Center is not full screen when a disc is inserted, Windows auto-play manages the playback process. • If an HD DVD or Blu-ray Disc disc is already in the DVD drive, Windows Media Center can start a third-party playback application if the user selects Play DVD from the Windows Media Center Start menu. To register an HD DVD or Blu-ray Disc playback application, use one of the two new categories for application registration: • AutoPlay\HD DVD • AutoPlay\Blu-ray Examples The examples below demonstrate how to register third-party applications with Windows Media Center as follows: • The first example registers Notepad.exe to start when an HD DVD disc is inserted while Windows Media Center is full screen. • The second example registers Calc.exe to start when a Blu-ray Disc disc is inserted while Windows Media Center is full screen. You could also register native Windows Media Center applications (MCML and hosted HTML). For external applications, you should ensure that Windows Media Center is restored to its previous position once the external application is closed. (For an example of how this looks, run any of the games that are included with Windows Media Center in the Extras Library.) Otherwise, if Windows Media Center is not automatically restored, the user will need to use a mouse or keyboard to return to it. To use these examples, save the XML files, and then register the applications as follows:
- Save the following XML to c:\notepad.xml:
- Save the following XML to c:\calc.xml:
- Run the following commands to register the applications: C:\Windows\ehome\RegisterMCEApp.exe /allusers c:\notepad.xml C:\Windows\ehome\RegisterMCEApp.exe /allusers c:\calc.xml
To display the applications in the Extras Library, you must register them in other categories with a separate registration. If more than one application is registered in each category, the user is prompted to select the playback application to use. If no applications are registered for HD DVD playback, the following dialog box is displayed:
If no applications are registered for Blu-ray Disc playback, the following dialog box is displayed:
- Run the following commands to remove these example applications from the registry: C:\Windows\ehome\RegisterMCEApp.exe /u /allusers c:\notepad.xml C:\Windows\ehome\RegisterMCEApp.exe /u /allusers c:\calc.xml
See Also • Allowing Applications to Handle AutoPlay Events
Windows Media Center enables software vendors to create applications that provide CD or DVD recording capabilities, and to tightly integrate those capabilities into Windows Media Center. CD/DVD recording applications use the IListMakerApp interfaces of the Windows Media Center application object model to get lists of digital media files from the user, and they use the IDiscWriterApp interface to record the media files onto a CD or DVD. A CD/DVD recording application is a managed software component provided by an independent software vendor. It runs inside the Windows Media Center process, using the API elements exposed by the Microsoft.MediaCenter.ListMaker namespace to exchange file and disc information with Windows Media Center, and to retrieve lists of user-selected files for recording onto a CD or DVD. This section discusses the following topics: Topic Description Retrieving File Lists from Windows Media Center Describes how to use the IListMakerApp interface to retrieve file lists from Windows Media Center. Exchanging Disc Information with Windows Media Center Describes how a CD/DVD recording application exchanges disc information with Windows Media Center through the IDiscWriterApp interface.
Registering a CD/DVD Recording Application Describes how to register an application with Windows Media Center.
See Also • Developing Applications for Windows Media Center
A CD/DVD recording application uses the list-making capabilities of Windows Media Center to retrieve files that the user has selected, and then records the files onto a CD or DVD. To access the list-making capabilities, an application must implement the IListMakerApp interface. Windows Media Center uses this interface to exchange file and disc information with the application. When the user has selected files for a CD or DVD recording operation, Windows Media Center starts a registered CD/DVD recording application by calling the application's IListMakerApp.CanProceed property. Windows Media Center passes an instance of the ListMakerList interface to the IListMakerApp.Launch method, along with a CompletionCallback delegate. The ListMakerList interface is implemented by Windows Media Center. It provides access to a collection of files that the user has selected. Each item in the file collection is an object that exposes the ListMakerItem interface. An application uses this interface to retrieve detailed information about the files that the user has selected for recording. An application uses the IListMakerApp.ProgressChanged event to send progress updates to Windows Media Center, and uses the CompletionEventHandler delegate to notify Windows Media Center when the recording operation has been completed. When the user adds or removes files after an application's CanProceed property was called, Windows Media Center notifies the application by calling the IListMakerApp.ItemAdded and ItemRemoved methods. Both methods receive a ListMakerItem interface that provides access to the information about the deleted file. An application's ListMakerApp interface includes a set of read-only properties. Windows Media Center queries these properties to retrieve configuration parameters from the application. See Also • CD and DVD Content Burning
A CD/DVD recording application for Windows Media Center must implement the IDiscWriterApp interface. Windows Media Center uses this interface to retrieve information from the application, including the available drives, the supported recording formats, the currently selected drive, and so on. Windows Media Center also provides disc-related information to the application through this interface. Currently, the IDiscWriterApp interface is responsible for selecting a writeable CD/DVD from the computer’s available drives. In the future, Windows Media Center will display a list of disc drives that are capable of writing data to a CD or DVD, and enables the user to select a drive from the list. Windows Media Center gets the list from the CD/DVD recording application's IDiscWriterApp.AvailableDrives property. After the user selects a drive, Windows Media Center informs the application by setting the IDiscWriterApp.SelectedDrive property. To find out which drive the application is using for the current recording operation, Windows Media Center can retrieve the IDiscWriterApp.InUseDriveLetter property. For Windows Media Center in Windows Vista, these interfaces are unused. An application indicates the disc recording formats that it supports by setting the IDiscWriterApp.SupportedFormat property to an array of values from the DiscFormats enumeration. Windows Media Center uses the values to offer a list of formats to the user. When the user selects one, Windows Media Center relays the selection to the application by setting the IDiscWriterApp.SelectedFormat property. An application can support the IDiscWriterApp.Erase method to enable the user to erase files from the recording medium. If the current medium is read/write capable and contains data, the application should set its IDiscWriterApp.IsErasable property to true. Before calling the application's Erase method, Windows Media Center checks the IsErasable property to determine whether the application can perform the erase operation. If the application supports the fit-to-disc feature, it should set the IDiscWriterApp.SupportsFitToDisc property to true. When this property is true, Windows Media Center offers the user the option of using fit-to-disc. The IDiscWriterApp.FitToDisc property indicates the current status of the fit-to-disc feature. See Also • CD and DVD Content Burning
All CD/DVD recording applications must implement the IAddInEntryPoint interface. Further, all applications must be properly registered with Windows Media Center, either by calling the ApplicationContext.RegisterApplication method or through the RegisterMCEApp.exe command-line tool. See Also • CD and DVD Content Burning