NMD UI (Windows CE 5.0)

Send Feedback

The Sample application is made up of the following files:

  • NMDApp.cpp
    This class is the entry point to the application. It initializes the libraries, verifies that the device resolution is valid and starts the application.
  • These pages all use ODLIB to draw user-interface elements to the screen.
    MainMenu.cpp
    This is the main menu page. Also handles data loading and event processing for server changes.
  • MyView.cpp
    This is the base class for the data view pages. This does all the real work of displaying a view page. It creates the buttons, listbox etc.
  • MyPictures.cpp
    MyVideo.cpp
    MyMusic.cpp
    These customize the view page with the data type specific information (icon, title, content type)
  • DisplayMode.cpp
    This 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 playlist. Allows manipulation of the items in the playlist and entry to the options for the playlist.
  • MyPlaylistOptions.cpp
    This is the playlist options page. Options available depend on the type of playlist being shown (there are 3 active playlists, one each for music, video and pictures).
  • Details.cpp
    This page shows the details for an item when it is selected. The details shown depend on the type of the item. This provides a good example how to get specific information about an item from the MQE.
  • NowPlaying.cpp
    This page is displayed when a playlist is playing.
  • Playlist_Files.cpp
    This page provides playlist load and save functionality, does file name entry for save and allows picking a file name (for load). Although disabled in the NMD UI, this code will work and can be enabled. See the sample readme for information about why this feature is disabled.
  • EditPage.cpp
    This is a utility page used by the settings pages when a data field needs to be changed. This interacts with the SIP to allow a remote controlled SIP input.
  • PlaylistManager.cpp
    This is the central point for the playlists. Holds the 3 playlists, also coordinates resource usage between playlists. For example, if a picture playlist is playing, do not allow a video playlist to play as there is only one display surface.
  • Playlist.cpp
    This provides the actual playlist functionality.
  • PlaylistItem.cpp
    This is the heart of the playlist. This file contains most of the code that actually plays content. It includes calls to DirectShow to play back music and video and a wrapper for picture streaming (Pictures do not go through DirectShow).
  • Metronome.cpp
    This starts a thread that sends a message to the playlist / now playing page. It is used to update the music playback progress bar and cause picture changes during slideshows.
  • BatchScheduler.cpp
    This is a scheduler that runs a thread to do background data caching.
  • DataSourceStore.cpp
    This is a collection of all the MQEDataSource objects used to feed the view listboxes.
  • MQEDataSource.cpp
    This is a wrapper for a MQE query, and 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 a MQE batch that allows you to keep the relevant thumbnails attached the batches.
  • MQESink.cpp
    This is the event sink for all the MQE Events.

Utility Files

  • SimpleDataSource.cpp
    Sliding list boxes (the list boxes used for views) require a data source. This is a simple sample list based data source.
  • MediaPerfCounters.cpp
    This is used for performance tracking after the end of DirectShow media playback.

The following files contain source code for NMD settings:

  • AdapterListener.cpp
    This class contains the adapter listener thread, which listens for changes in adapter state.
  • IPAddressInfo.cpp
    This class contains the IP address info for an adapter. This class is used to communicate information about the IP address of adapter to the UI class.
  • MediaServersImpl.cpp
    This class interacts with the Media Query Engine to get an updated list of media servers. It also dismisses the Waiting for Authorization dialog box when the WMC sends a device authorized event.
  • NameServersInfo.cpp
    This class contains name servers information for the network adapter.
  • NetAddressString.cpp
    This class converts an IP address to a string and performs conversion operations.
  • NetworkDataStore.cpp
    This class is main information source for network settings data. The network data source manages listener threads and maintains network data for available networks.
  • NetworkSettingsInfo.cpp
    This class contains the information displayed in current network settings page.
  • RegistryAdapterData.cpp
    This class interacts with the registry to obtain adapter specific data. When the user makes changes to names or IP or name server settings, this class saves the data and restarts the adapter to make the changes effective.
  • SettingsDataStore.cpp
    This file 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 WZC (Wireless Zero Configuration) to obtains latest list of wireless networks.
  • WirelessZeroConfig.cpp
    This file implements the functionality to connect to the wireless network.
  • WZCInterface.cpp
    This is shim for wzcapi.dll
  • 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 wlan configuration contains encryption, authentication and mode 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
    This file contains the user interface for the Settings->About page.
  • ChangeIPAddress.cpp
    ChangeNameServers.cpp
    ChangeNetworkSettings.cpp
    CurrentNetworkSettings.cpp
    These pages show 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
    This page displays current name of the NMD device. This is the name that is displayed in the Windows Media Connect (WMC) device list. The user can change the device name in this screen. The name change propagates to WMC and the name is refreshed in the WMC list.
  • MainMenu.cpp
    This contains the main menu for NMD settings.
  • MediaServerDetails.cpp
    This page displays the 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
    This page displays the list of media servers.
  • NetworkMenu.cpp
    This page presents the network menu options. Based on the present adapters, the user interface presents buttons for wired and/or wireless network settings options.
  • NetworkSettingsMenu.cpp
    This page has menus for the wired and wireless network. For 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
    This file loads the resource strings from the resource file.
  • UIEffects.cpp
    The page contains the options for UI effects.
  • VideoDisplay.cpp
    This page contains the video display options.
  • WirelessConnectPage.cpp
    This page gives the user the option to connect to a particular wireless network. The page prompts the user to enter the network key.
  • WirelessNetworksPage.cpp
    The page presents a list of the wireless networks visible to the NMD device.

Data Flow in NMD_UI

Start-up Data Flow

There is an initial data load pass to seed all the data queries and then the data pre-cache is filled by way of a background update thread.

  • In CMainMenuPage::Show, in the file MainMenu.cpp, the server is checked against the last active server. If these do not match a WM_APP_WMC_NewServer message is sent to the top window.
  • This message is processed in CMainMenuPage::ALProcessMessage
  • A dialog is displayed to the user "Loading initial data set" and g_DataStoreManager.InitDataSources 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.
  • Once the initial data set is loaded a WM_APP_DataStore_DataReady message is sent. This is once again processed in the main menu message procedure. It then sends a WM_APP_WMC_ActiveServer message.
  • WM_APP_WMC_ActiveServer processing enables the menu buttons and clears the busy state. This clears the loading dialog.

Data Cache Flow

The 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 required page is centered in the data cache by the CMQEDataSource::FindPage method. This sets m_pCurrentPage to the required page.

The last thing done by FindPage is to schedule a background update of the data cache for the data source by calling g_BatchScheduler.ScheduleUpdate. This puts an entry into the background batch scheduler. The scheduler then walks through the list of scheduled objects and makes a call to the objects ScheduledUpdate method.

In the case of the data source that is CMQEDataSource::ScheduledUpdate. This checks to make sure that there is at least two pages previous and after the current page loaded into the data cache.

To insure that the working set does not grow overly large it then does a trim pass to make 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 main menu
Escape VK_Escape Exit the current page
Backspace VK_Back Return up a level when you have drilled into a folder
Enter VK_Return Select item (referred to as "Select" in on screen messages)
F2 VK_F2 Add To playlist
F3 VK_F3 Play playlist
F4 VK_F4 View playlist
F5 VK_F5 Add all to playlist
F10 VK_F10 Fast Forward (This may or may not work depending on support for content type)
F11 VK_F11 Rewind (This may or may not work depending on support for content type)
F12 VK_F12 Play (will immediately play currently selected item)
Delete VK_DELETE Delete an item when viewing playlist
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 function CNMDApp::PreProcKeysImp which can be used to remap remote controls keys into the keys the UI expects. This allows you to quickly get started when you do not directly control the key-codes on the remote control you are using.

This is used in the sample application to remap some of the FKeys 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;
            }
         }
      }
}

See Also

Networked Media Device Sample Application

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.