My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MsnMsgrUiManager  
A Win32 window class implemented by MSN Messenger and other compatible messengers
Phase-Implementation, Featured
Updated Jul 10, 2011 by segin2005

Introduction

The MsnMsgrUiManager window class is implemented by Windows Live Messsenger, MSN Messenger, and by any messenger application (or associated plugins thereof) that wish to receive "Now Playing" data from any media player application that supports sending such data to MSN Messenger.

Known Implementations

Messengers

The following instant messaging applications are known to implement the receiving end of the interface:

Libraries

Libraries that implement the receiver interface on the behalf of a messenger or status-display app:

  • libMsnMsgrUIManager - which in fact is implemented using this exact documentation page for interface specs.

Media Players

The following media players are known to implement the sending end of the interface:

Details

The MsnMsgrUiManager Now Playing interface is rather straightforward. The sender program (the media player) sends a WM_COPYDATA message to any and all windows matching the MsnMsgrUiManager window class using the SendMessage() function.

The WM_COPYDATA message type requires the use of the COPYDATASTRUCT struct, which has three defined elements:

  • dwData, which indicates the data type. This should be 1351 when sending updates to the media player.
  • cbData, which indicates the length of the data buffer (in bytes) pointed to by lpData, and finally
  • lpData, which is a pointer to a buffer containing the data to be passed via SendMessage()

The actual message data passed via lpData is a wide-character string, terminated by a null character. The data fields are delimited by literal wide-character "\0" (literal backslash and literal zero, NOT a null-value wide character).

The fields are described below:

  1. [iTunes extension] Player name. If you don't really care, leave it empty.
  2. Message type. There a number of things you could put here, but the only important value for this is "Music".
  3. Status Enabled. Does the message enable or disable the now playing information? When announcing a new song, this is "1", and at the end of a song (to clear the now playing from the messenger), this is "0".
  4. Format string. This is only really important for MSN Messenger and Windows Live Messenger. It is either string data to be used literally, or tokens referencing the argument strings, which come next. Each argument is referenced by it's argument number, starting with 0, enclosed in curly brackets ("{" and "}").
  5. Song Title. This is the first argument string, and is the title of the song.
  6. Artist. This is the second argument string, and is the name of the song artist.
  7. Album. This is the third argument string, and is the name of the album which the song is on.
  8. WMContentID. This is the string "WMContentID".

So, in order, the final string looks like this (remember, this is entirely literals, nothing here is really escaped): "1\02\03\04\05\06\07\08\0"

Now, assume the following information:

Then you would get the string:

"PsyMP3\0Music\01\0PsyMP3: {1} - {0}\0Through The Fire And Flames\0Dragonforce\0Inhuman Rampage\0WMContentID\0".

The format string is only used by Windows Live Messenger, and it would set the display on Windows Live Messenger to say "PsyMP3: Dragonforce - Through The Fire And Flames".

You could omit the opening "PsyMP3" and start off with the first "\0"; the player name field there is an extension that originates from iTunes.

Remember to escape the backslash in C strings, e.g. "\\0" in C (to get literal "\0")

Once you have the string formatted, set the lpData element in the COPYDATASTRUCT struct to be the pointer to the message string. Set the cpData field to be length of the string, in characters, doubled, with two added after that, or in C, ((wcslen(message) * 2) + 2). Finally, set the dwData element to 1351.

Once you have the COPYDATASTRUCT structure filled out, now it's time to pass it to the instant messenger application via SendMessage(). The first argument to SendMessage() will be the window handle to the messenger window (which you should have found using either FindWindow() or preferably FindWindowEx()). The second argument, the message type, is WM_COPYDATA, while the wParam argument (the third argument) is the hWnd of your program's window - you can set this to 0 if it is not applicable. The lParam argument (final argument for SendMessage) will be the pointer to the COPYDATASTRUCT structure.

To clear the now playing from the messenger, send a message string with field 3 being "0" instead of "1".

For more information, please reference the implementation in the PsyMP3 source code.


Sign in to add a comment
Powered by Google Project Hosting