NMD UI (Windows Embedded CE 6.0)
1/5/2010
The Networked Media Device Sample application is made up of the following files located in the %_WINCEROOT\PUBLIC\DIRECTX\OAK\SAMPLES\NMD\UI folder.
- NMDApp.cpp
The entry point to the application. It initializes the libraries, verifies that the device resolution is valid, and starts the application.
Display-related Pages
These pages all use Owner-Draw Library (ODLIB) to draw user interface elements to the screen.
- MainMenu.cpp
The main menu page that handles data loading and event processing for server changes.
- MyView.cpp
The base class for the data view pages that does all of the real work to display a view page. It creates the buttons, list boxes and other visual elements.
- MyPictures.cpp
Customizes the view page with the data type specific information (icon, title, or content type).
- MyVideo.cpp
Customizes the view page with the data type specific information (icon, title, or content type).
- MyMusic.cpp
Customizes the view page with the data type specific information (icon, title, or content type).
- DisplayMode.cpp
Acts as the central location that combines display information with the data source for the list view.
- MyPlaylist.cpp
This page is used to view the current play list. Allows manipulation of the items in the play list, and allows entry to the options for the play list.
- MyPlaylistOptions.cpp
This is the play list options page. Options available depend on the type of play list that are being shown (there are three active play lists: one each for music, video, and pictures).
- Details.cpp
This page shows the details for an item on a page when an item is selected. The details that are shown depend on the type of the item. This page provides a good example for getting specific information about an item from the Media Query Engine (MQE).
- NowPlaying.cpp
This page is displayed when a play list is playing.
Playlist_Files.cpp
This page allows the user to load and save play lists, and enter and pick file names.Although disabled by default in the networked media device (NMD) UI, you can enable it. For more information about why this feature is disabled, see the readme provided with the sample.
- EditPage.cpp
This is a utility page used by the settings pages when a data field needs to be changed. This utility page interacts with the software-based input panel (SIP) to allow a remote controlled SIP input.
Play List-related Files
These files contain the classes that manage play lists on the device.
- PlaylistManager.cpp
This central point for the play lists holds the three play lists and also coordinates resource usage among play lists.
- Playlist.cpp
Provides the actual play list functionality.
- PlaylistItem.cpp
Contains most of the code that actually plays content. It includes calls to Microsoft DirectShow to play back music and video and provides a wrapper for picture streaming (pictures do not go through DirectShow).
- Metronome.cpp
Starts a thread that sends a message to the play list or the Now Playing page. This file updates the music playback progress bar and causes picture changes during slideshows.
MQE-related Files
- BatchScheduler.cpp
This is a scheduler that runs a thread to do background data caching.
- DataSourceStore.cpp
This is a collection of all MQEDataSource objects that are used to feed the view list boxes.
- MQEDataSource.cpp
This is a wrapper for an MQE query, and it contains the query parameters and batch size information. It also maintains a list of CMyBatch objects, each of which contains a batch (page) of data.
- ThumbnailBatch.cpp
This is a wrapper for an MQE batch that allows you to keep the relevant thumbnails attached to the batches.
- MQESink.cpp
This is the event sink for all of the MQE events.
Utility Files
- SimpleDataSource.cpp
This is a simple sample list–based data source. Sliding list boxes (the list boxes used for views) require a data source.
- MediaPerfCounters.cpp
This is used for performance tracking after the end of DirectShow media playback.
Settings-related Files
The following files contain source code for NMD settings.
- AdapterListener.cpp
Contains the adapter listener thread, which listens for changes in the adapter state.
- IPAddressInfo.cpp
Contains the IP address information for an adapter and communicates the information about the IP address of adapter to the UI.
- MediaServersImpl.cpp
Interacts with the Media Query Engine to get an updated list of media servers. It also dismisses the Waiting for Authorization dialog box when Microsoft Windows Media Connect (WMC) sends a device authorized event.
- NameServersInfo.cpp
Contains name servers information for the network adapter.
- NetAddressString.cpp
Converts an IP address to a string and performs conversion operations.
- NetworkDataStore.cpp
Is a main information source for network settings data. The network data source manages listener threads and maintains network data for available networks.
- NetworkSettingsInfo.cpp
Contains the information that the Current Network Settings Page displays.
- RegistryAdapterData.cpp
Interacts with the registry to obtain adapter-specific data. When the user makes changes to names, IP, or name server settings, this class saves the data and restarts the adapter to make the changes effective.
- SettingsDataStore.cpp
Contains settings for UI effects, video display, and play list options. It also makes the settings persist.
- WiFiNetworksInfo.cpp
The WiFi network information class interacts with Wireless Zero Configuration (WZC) to obtain the latest list of wireless networks.
- WirelessZeroConfig.cpp
Implements the functionality to connect to the wireless network.
- WZCInterface.cpp
This is shim for the wzcapi.dll file.
- WZCListener.cpp
This is a thread that listens for messages for WZC. The WZC messages include information about current connection status with a wireless network.
- WZCWlanConfig.cpp
The wireless local area network (LAN) configuration contains encryption, authentication, and modes for a wireless network.
User Interface Pages for Settings
The following files contain source code for the user interface pages for the NMD settings.
- About.cpp
Contains the user interface for the About page.
- ChangeIPAddress.cpp
Shows the current network settings for the wired and wireless interfaces. The Change IP Address and Name Servers page allows these values to be changed and saves the new values.
- ChangeNameServers.cpp
Shows the current network settings for the wired and wireless interfaces. The Change IP Address and Name Servers page allows these values to be changed and saves the new values.
- ChangeNetworkSettings.cpp
Shows the current network settings for the wired and wireless interfaces. The Change IP Address and Name Servers page allows these values to be changed and saves the new values.
- CurrentNetworkSettings.cpp
Shows the current network settings for the wired and wireless interfaces. The Change IP Address and Name Servers page allows these values to be changed and saves the new values.
- DeviceName.cpp
Displays the current name of the NMD, which is displayed in the Windows Media Connect device list. The user can change the device name on this screen. The name change propagates to WMC, and the name is refreshed in the WMC device list.
- MainMenu.cpp
Contains the main menu for NMD settings.
- MediaServerDetails.cpp
Displays the unique device name (UDN) and current status of the selected media server. It allows the user to activate a server or make a server the current content provider.
- MediaServers.cpp
Displays the list of media servers.
- NetworkMenu.cpp
Presents the network menu options. Based on the present adapters, the user interface presents buttons for wired and wireless network settings options.
- NetworkSettingsMenu.cpp
This page has menus for the wired and wireless network. For a wired network, the options are Current Network Settings and Change Network Settings. For the wireless network, the options are Change Network Settings, Current Network Settings, and Wireless Networks.
- ResourceStringLoader.cpp
Loads the resource strings from the resource file.
- UIEffects.cpp
Contains the options for UI effects.
- VideoDisplay.cpp
Contains the video display options.
- WirelessConnectPage.cpp
Gives the user the option to connect to a particular wireless network. The page also prompts the user to enter the network key.
- WirelessNetworksPage.cpp
Presents a list of the wireless networks that are visible to the NMD device.
Startup Data Flow
There is an initial data load pass to initialize all of the data queries, and then a background update thread fills the data precache.
- In the CMainMenuPage::Show method in the MainMenu.cpp file, the server is checked against the last active server. If these servers do not match, a WM_APP_WMC_NewServer message is sent to the top window.
- This message is processed in the CMainMenuPage::ALProcessMessage method.
- A dialog, Loading initial data set, is displayed to the user, and the g_DataStoreManager.InitDataSources function is called. This function resets the data caches and then creates a new set of base queries. Each query then loads its first page of data.
- After the initial data set is loaded, a WM_APP_DataStore_DataReady message is sent, followed by a . WM_APP_WMC_ActiveServer message. These messages are also processed in the CMainMenuPage::ALProcessMessage method.
- Processing the WM_APP_WMC_ActiveServer message enables the menu buttons and clears the busy state. This step clears the loading dialog.
Data Cache Flow
The Networked Media Device Sample application reads data from the Windows Media Connect server in a paged manner. When a row of data is requested from the CMQEDataSource class, which is contained in the MQEDataSource.cpp file, the CMQEDataSource::FindPage method centers the required page in the data cache. This method sets the m_pCurrentPage property to the required page.
Lastly, the FindPage method schedules a background update of the data cache for the data source by calling the g_BatchScheduler.ScheduleUpdate method. This method puts an entry into the background batch scheduler. The scheduler then walks through the list of scheduled objects and makes a call to the object's ScheduledUpdate method.
CMQEDataSource::ScheduledUpdate checks that there is at least two pages before and after the current page that is loaded into the data cache.
To ensure that the working set does not grow too large, this method performs a trim pass to be sure that the total set of cached pages for this data source is not more than 9.
Exiting the Application
To exit the application during testing and development, press CTRL+SHIFT+ESC or CTRL+ESC.
Key Codes
You can design your hardware to respond to front-panel and remote control key presses by sending the following key codes to the sample application through the keyboard driver.
Name |
Key code |
Description |
HOME |
VK_Home |
Return to the main menu. |
ESC |
VK_Escape |
Exit the current page. |
BACKSPACE |
VK_Back |
Return up a level when you have drilled into a folder. |
ENTER |
VK_Return |
Select an item (referred to as Select on-screen messages). |
F2 |
VK_F2 |
Add to play list. |
F3 |
VK_F3 |
Play a play list. |
F4 |
VK_F4 |
View a play list. |
F5 |
VK_F5 |
Add all to a play list. |
F10 |
VK_F10 |
Fast forward (this action may or may not work depending on the support for content type). |
F11 |
VK_F11 |
Rewind (this action may or may not work depending on the support for content type). |
F12 |
VK_F12 |
Play, which immediately plays the currently selected item. |
DELETE |
VK_DELETE |
Delete an item when viewing a play list. |
UP ARROW |
VK_UP |
|
DOWN ARROW |
VK_DOWN |
|
LEFT ARROW |
VK_LEFT |
|
RIGHT ARROW |
VK_RIGHT |
|
Remote Control Key Code Remapping
The NMD UI has a CNMDApp::PreProcKeysImp function, which you can use to remap remote controls keys into the keys that the UI expects. Remapping allows you to quickly get started when you do not directly control the key codes on the remote control that you are using.
The following code example is used in the sample application to remap some of the function keys into media keys.
void CNMDApp::PreProcKeysImp(MSG &rMessage)
{
// virtual method
switch (rMessage.message)
{
case WM_KEYUP:
case WM_KEYDOWN:
{
switch (rMessage.wParam)
{
case VK_F10:
{
//TRACE(TEXT("Remaping VK_F10 to VK_PRIOR"));
rMessage.wParam = VK_PRIOR;
}
break;
case VK_F11:
{
//TRACE(TEXT("Remaping VK_F11 to VK_NEXT"));
rMessage.wParam = VK_NEXT;
}
break;
case VK_F12:
{
//TRACE(TEXT("Remaping VK_F12 to VK_PLAY"));
rMessage.wParam = VK_PLAY;
}
break;
}
}
}
}