REQ: Windows Media Player help

In addition to supporting “standard” podcasting in FeedDemon, I’d also like to enable clicking an enclosure to add it to the current Windows Media Player playlist. In Explorer, you can do this by right-clicking an MP3 and choosing “Add to Now Playing List,” but this feature is apparently buried inside wmpshell.dll and isn’t exposed anywhere, nor can it be done using a command line parameter.

If you’re a developer and you know how to do this programmatically, please let me know! I’d be happy to give you free copies of both TopStyle and FeedDemon in return.

39 thoughts on “REQ: Windows Media Player help

  1. You might want to look at IWMPPlaylist. appendItem looks a good candidate.
    Note that I have never done this, just did a couple of quick searches and dug this up. HTH.

  2. Randy, Doppler adds the download to a playlist, but it doesn’t add it to the “Now Playing” playlist, which is what I want to do. My goal is to enable building the current playlist by clicking a series of enclosures, and have them automatically play in sequence.

  3. Unfortunatly for you, I have to go to a birthing class (wife’s due in dec/jan).
    But here’s how I would go about solving this issue.
    We know from looking in the registry that “wmpshell.dll” acts as a context menu handler (look on for more cool info)
    [registry: HKEY_CLASSES_ROOT\CLSID\{F1B9284F-E9DC-4e68-9D7E-42362A59F0FD}]
    [registry: HKEY_CLASSES_ROOT\mp3file\shellex\ContextMenuHandlers\WMPAddToPlaylist]
    Using the OLEView tool (comes with DevStudio6), go to the View>View Typelib menu option.
    Select wmpshell.dll.
    Notice the
    helpstring(“WMPAddToPlaylistLauncher: Not Public. Internal object used by Windows Media Player.”)
    coclass WMPAddToPlaylistLauncher {
    [default] interface IUnknown;
    It has the same CLSID!
    What you need to do CoCreateInstance of WMPAddToPlaylistLauncher, and QueryInterface for IContextMenu (ot IContextMenu2 or 3) and call IContextMenu::InvokeCommand.
    I would suggest reading the MSDN KB titled “Creating Shortcut Menu Handlers” as well as the excelent “The Complete Idiots Guide to writing shell extensions” on
    Later, I’m off to learn how to change a diaper.

  4. I did a bit of digging around with media player to try and accomplish what you want and so far I’ve come kind of close. First WMP stores the now playing list (XP) in “C:\Documents and Settings\Administrator\Application Data\Microsoft\Media Player\1501563B.wpl” Obviously it would vary with the user account and the file name may be different as well.
    I found that I could add to the XML in the file, however, it would not update automatically in WMP. Some further testing and I found I could load the now playing list by via the command line ‘wmplayer.exe “C:\Documents and Settings\Administrator\Application Data\Microsoft\Media Player\1501563B.wpl”‘ However, that starts the playlist at the first item on the list. And it calls it 1501563B rather than now playing, so technically it’s loading it as a seperate playlist.
    If there is a way to ‘refresh’ the now playing list to sync it up with the xml file perhaps you could go that route.

  5. Clicked Post too quickly. Basically the code found at the url above will create an instance of context menu, interrogate it to find the Enqueue item by language-independent verb (WMPEnqueue) and invokes it. It is uses pieces of code provided by Raymond Chen in his blog (The Old New Thing)

  6. Reading a little deeper:
    Once you have verified that the user has Windows Media Player 9 Series or Windows Media Player 10 installed, you can use the Player.openPlayer method to open the content in the full-mode Player. The openPlayer method ensures that your content is initially displayed in the Now Playing feature of the full-mode Player, rather than in a skin, in mini Player mode, or in another player that has registered itself as the default program for files with an .asx file name extension, but doesn’t support HTMLView.
    You can then call player.currentPlaylist to get the current playlist
    You can then use player.currentPlaylist.appendItem(item)
    Best Regards

  7. Wow – thanks for all the great suggestions! I’ll be tackling this throughout the day, and I’ll follow-up here if/when I get it working.
    Jason, your approach is the one I had been working on, but I was concerned about relying on an unexposed feature in wmpshell.dll. MS could change the behavior down the road, which would mean this feature could stop working in FeedDemon.
    Steve, I spent several hours with the WMP SDK yesterday, but somehow missed the fact that Player.openPlayer will open the file in the full player – everything else I tried opens an embedded WMP, so your approach may be the solution. Thanks!

  8. Slightly off topic but related to this….
    It would be nice if you supported Winamp as well. Any plans to do this?

  9. Unexposed, pfft! what isn’t. ;-)
    So much for the free reg, on the plus side I know know more than I ever wanted to know about lactation! (yay?)

  10. So perhaps you want to reconsider the Context menu approach. At the very least we know that the verb name has not changed between WMP 9 and 10 (and the feature did not exist prior to WMP 9), so one can expect that it will be there for a while.

  11. Nick, I’m not sure if this is what you’re after but… The following code will add the given song to the “Now Playing List”. It’s pretty simple but you’ll need to translate to Pascal. :-)
    ::ZeroMemory(&si, sizeof(SHELLEXECUTEINFO));
    si.cbSize = sizeof(SHELLEXECUTEINFO);
    si.lpVerb = “open”;
    si.lpFile = “c:\\temp\\abc.wma”;

  12. Thanks for the tip, Rob. Unfortunately, this doesn’t do what I’m looking for. It adds the file to the now playlist list – but it also removes everything else from the list and starts playing immediately. What I’m wanting to do is add the file to the current now playing list, so that you can simply click several enclosures in FeedDemon and listen to them all in a row.

  13. Nick,
    That’s kind of what I thought. The neat thing about using ShellExecuteEx is it will instantiate IContextMenu and call IContextMenu::InvokeCommand for you with the given verb.
    I think it’s the correct way to go IF you can figure out what verb to use because you only have to make a single call to invoke it.
    Now if you could get someone to tell you the verb for add something to get “Now Playing List” you’d be skating.
    Heck, you may want to try ‘add’ as the name of the verb and see what happens?

  14. Nick,
    A quick search of IContextMenu::InvokeCommand is what lead me to post the ShellExecuteEx sample. URL below…
    The docs for IContextMenu::InvokeCommand say you can “…invoke this method indirectly by calling ShellExecute or ShellExecuteEx and specifying a verb…”
    I won’t claim to be an expert on the IContextMenu interface or the ShellExecuteEx API, so maybe I was too hasty and didn’t read far enough to find caveats?

  15. Kevin, I just searched for information on scripting WinAMP, and came across the news that it’s no longer being developed
    Until just recently neither was MSIE. What’s your point?
    Btw, how did you like Brand New?

  16. From what I know of Windows Media Player, the playlist functionality is defined in the following interfaces that are implemented in the ‘wmp.dll’ interface:
    Descriptions of each of these interfaces and implementations can be obtained from the Microsoft Windows Media Player SDK which is freely available from Microsoft.
    Darryl Staflund

  17. Err, “…’wmp.dll’ interface…” should read “…’wmp.dll’ component…”.
    Darryl Staflund

  18. Marco, thanks for the example code – but unfortunately, it doesn’t do what I’m looking for. What I need to do is add a file to the “Now Playing” playlist, so that it’s added to the queue. In other words, I want to enable FeedDemon customers to click a series of audio enclosures and have them automatically play in order.

  19. On Winamp no longer being developed… Have you looked at Winamp? What needs to be done on it? ;-)
    It is pretty much a complete product as it is. I can’t think of anything I’d want added to it. Although…. I would like it to default to using Firefox rather than IE. But that’s the only thing and I can live with that. After all, FeedDemon’s already counting me as a IE user on evey site I visit with it- when in reality I’m an exclusive Firefox user!! That’s why I don’t believe browser statistics at all. Everyone I know is using Firefox: friends, family and now our whole company uses it (not a big company though: 9 people). Even the “building maintenance” guy mentioned Firefox the other day!!
    Anyway, the news of Winamp no longer being developed is not official. Only the “original developers” have left the project. While that sounds like a death-knell it may not be. Think about Delphi… how many of the original developers are working on it now? Many have left and the product is incredibly strong still.
    Until there’s some proof that the product is really no longer being developed I will keep on using it.
    Besides… Winamp is so _EXTENSIBLE_ that the community will continue extending it ad infinitum.

  20. here’s a working code in python. it shouldn’t be so different from c++.
    (tested with activestate python)
    from win32com.client import Dispatch
    # get Media Player COM object
    wmp = Dispatch(“WMPlayer.OCX”)
    # play a file !
    # new file
    newItem = wmp.newMedia(“c:/b.mp3”)
    # append new file to playlist
    # print current media name
    # play next in playlist
    # print current media name

  21. Thanks, Edward, but this still doesn’t add to the “Now Playing” list. I need to add a file to WMP’s “Now Playing” list so that it’s automatically played in the order that’s it added.

  22. had an error in the python code:
    # play next in playing
    and it’s not really working as expected… the control commands are not passed to the Media Player with the UI. It feels like there is an invisible player apart from the UI. if is used instead of openPlayer() it works well (but without the UI).

  23. I want to use WMP 9 or WMP 10 to stream encoded video to wireless PDAs with PPC. I want to use my own decoder plug-in. I was told it is not possible to use a plug-in for PPC with the SDK for WMP9 available. Any response?

Comments are closed.