Announcing Moonshine, the project never formerly known as Pornilus

For the last month, I have been working on a new project officially called Moonshine, but referred to as “Pornilus” in some affluent circles.

Moonshine is a project based on Moonlight that leverages the built-in Windows Media capabilities of Silverlight to bring Windows Media playback to Linux in a fully legitimate way, without forcing the end user worry about what a codec is. This is possible because Microsoft provides the codecs directly to all Moonlight users, regardless of their choice of Linux distribution.

Very simply, Moonshine:

  • Allows an end user to experience Windows Media content on the web.
  • Brings Windows Media playback capabilities to a user’s desktop for playing local/arbitrarily downloaded content.

Moonshine powering HBO and C-SPAN

Install Moonshine

Of course you’ll also need Moonlight installed. If you don’t have the
proper version installed, the Moonshine page will tell you.


On the Moonshine page, there is an XPI available to install for Firefox. You must have the latest Moonlight installed and Firefox 3.0 or newer. The Firefox shell that provides local media playback however is not part of the XPI. You must build Moonshine from source to have this feature. Packages will soon be available for openSUSE, and hopefully for other distributions soon.

Additionally, you must disable the Totem GMP/Windows Media plugin in Firefox, since it basically tells Firefox it can handle the same Windows Media mime types, even if the codec is not installed for GStreamer. It would be really great if Totem would only advertise mime types that GStreamer actually supports on a given user’s system.

Moonshine Overview

The project consists of three components:

  • A media player written in Silverlight/JavaScript that stands on its own.
  • A Firefox/NPAPI plugin written in C that claims support for Windows Media mime types and enables embedded playback of Windows Media on the web.
  • A Desktop Application that allows local playback of Windows Media content, implemented in JavaScript as a XUL overlay that re-purposes Firefox’s user interface to be more appropriate to media playback instead of web browsing.

If you do not care about the really technical details of Moonshine, I’d advise you to stop reading now, and just install Moonshine and try it out! If you’re interested in the details of my life over the last month, read on!

The Silverlight Application

The actual media player for Moonshine is implemented in Silverlight/JavaScript using my MTK widget library. MTK uses the basic approach in GTK for widgetry. Many of the base concepts are similar: size requisitioning, allocation, parenting, realization, etc. To write the Moonshine player, I basically implemented GObject, GtkWindow, GtkWidget, GtkContainer, GtkBox, GtkHBox, GtkVBox, GtkButton, GtkLabel, and GtkScale, hastily of course.

MTK even supports a small level of native look-and-feel integration by reading system/theme colors from the browser’s CSS mapping.

It was still a really entertaining hack: MtkObject for example contains a simple virtual method and event implementation, which greatly simplified writing widgets. JavaScript purists who know better than I will probably bash this though, screaming something about “but think of the prototypes!”

All this effort was necessary as unfortunately Silverlight 1.0 (which Moonlight currently targets) does not offer a toolkit – it really is just a glorified canvas/stage. When Moonlight 2.0 is released, the MTK side of Moonshine will go away, though it would be very interesting to re-target MTK from XAML to say, SVG. I would love to see someone try that, it should be relatively straightforward.

What’s interesting about the Silverlight player is that it works as an entirely standalone Silverlight application, suitable for embedding on any web page. Of course though my JavaScript is very specific to Firefox 3.0+ I assume, so that kills a little value there. Patches welcome.

The Firefox Plugin

Finally, Moonshine provides an NPAPI plugin that advertises it supports Windows Media to Firefox. When Firefox comes across said media, it loads the Moonshine plugin. Moonshine in turn loads Moonlight, and proxies NPAPI calls directly to Moonlight. Moonshine then injects the Silverlight JavaScript into the browser, and binds it to the Moonlight plugin instance. From the browser perspective, it’s Windows Media, but the real stuff under the hood is just pure unadulterated Moonlight, driving a standard Silverlight application.

Additionally, a further piece of JavaScript is bound to the plugin object that emulates pieces of the standard Windows Media ActiveX/object API for further compatibility.

The implementation details on the Moonshine plugin are a bit interesting:

  • Moonshine provides the 4 standard NPAPI entry points: NP_Initialize, NP_Shutdown, NP_GetValue, and NP_GetMIMEDescription. It proxies each of these calls, excepting NP_GetMIMEDescription to Moonlight’s own NPAPI entry points.

  • Inside of NP_Initialize, Moonshine calls Moonlight’s NP_Intialize, and then overrides three NPP functions to be returned to the browser: NPP_New, NPP_StreamAsFile, and NPP_Destroy.

  • The NPP_StreamAsFile override simply prevents Moonlight from receiving that call, which would cause Moonlight to try to load WM content as XAML. The NPP_Destroy override just allows Moonshine to clean up its Moonlight binding on an instance, and then call’s Moonlight’s version of the function.

  • And finally, the juicy NPP_New override actually creates its own NPP_New call against Moonlight. All it sends to Moonlight is the width, height, and HTML DOM ID of the requested WM player, and sets the onload and source attributes on Moonlight to appropriate values for binding to the injected XAML/JavaScript player.

So this all means that Moonlight has absolutely no idea that the content its driving wasn’t hard coded in the web page. For all Moonlight is concerned, Moonshine is the browser. Plugins helping plugins, that’s what it’s all about.

And it all started as an extension

Moonshine was a really annoying project at first, and it took a while to come together. Most of the real progress and code that ultimately became Moonshine was written over the last two weeks.

Originally I wanted to avoid writing an NPAPI plugin and instead opted for writing a Firefox extension. What a mistake. I have learned way too much about Firefox and the Mozilla platform. It’s huge. But I must say, it was actually pretty pleasant to work with. Most APIs are pretty well documented. MDC is your friend, but a checkout of the Firefox source code is your better friend.

The mistake isn’t really the fault of the Mozilla platform, but a misunderstanding on my part of what I really needed to accomplish. My original version listened to the DOM, listened for new streams, etc. to intercept Windows Media mime types. This finally was working fairly well, but really was just a giant hack. I could not stomach the abuse I was causing inside the browser, and in no way was comfortable with releasing it.

However, the final nail in the extension approach was when I encountered web sites that actually check the plugin registry for a Windows Media plugin, and do not even create DOM content I could bind to if no plugin exists (ahh, gotta love the web). And of course the only way I could find to actually modify this registry was to be an NPAPI plugin.

So I threw away all of that code… about 1000 lines of JavaScript replaced with about a 1000 lines of C, an impressive trade-off — all things considered.

Going Forward, Looking Back

It’s been a very interesting few weeks, but I am so tired of working on this. I am aching to get back to Banshee. I do however want to make this work on the Mac under Microsoft’s own Silverlight. Or maybe someone out there can do it for me? It would be a fun hack!

Additionally, I am pretty interested in MTK, but can’t afford to work on it. I would be absolutely thrilled if someone would rebase the code on top of SVG. SVG needs a toolkit! It’s pretty pointless to continue working on MTK if it just targets XAML, since Silverlight 2.0 provides a toolkit. Any SVG/HTML5/Canvas enthusiasts out there are more than welcome to the MTK code. Keep me posted!

UPDATE: Last night I fixed a bug in Moonshine that prevented Moonlight from downloading the Windows Media codecs if you were running in plugin mode. If you experienced a “Bad address” error, please install the 0.2 XPI.

62 Replies to “Announcing Moonshine, the project never formerly known as Pornilus”

  1. Then use Totem… no need to be a dick. For a lot of users, figuring out how to install codecs is a nightmare. Distributions can actually ship Moonshine, and the user will get the codec with no fuss. For free. And legitimately. Oh, and considering the codec is actually FROM Microsoft, it actually will work with everything out there on the net! What a novel concept.

  2. Not to mention the fact that totem doesn’t work quite often even when people know what they’re doing.

  3. Ha, nice :)

    However, I don’t like the firefox-specific stuff… as this means Moonshine will be useless for users of Epiphany or, say, Chromium (soon!).

    Anyway, being mostly NPAPI, maybe this will get cross-browser support at some point?

  4. This is really great, it works seamlessly. I can now watch’s ‘five on demand’ on linux. It might sound feeble but it’s another barrier broken down. I shall never miss NCSI again.

  5. @Michael: In terms of the plugin portion of Moonshine there shouldn’t be any major Firefox specific code. I meant only that the player code was really just developed with some of the latest JavaScript language features (1.8). It should not be very hard at all to get working in WebKit + other JS engines, and this is indeed a goal of mine. I just had a very limited time to write this, and Firefox was my primary concern. This was however another one of the major reasons I decided to drop the extension in favor of NPAPI, and I probably should have mentioned this in the post.

    The Destkop Player however is of course xulrunner based, but the code here is extremely minimal (~100 lines JS and ~100 lines XUL markup) and could easily be redone to work with another platform.


  6. Yea, I’ve never been able to get the Totem browser plugin to work properly and I have the codecs. I’ve had to resort to building my own MPlayer and mplayer-plugin to get video on the web working.

    Thankfully now I can just use Pornilus… *cough* I mean Moonshine ;-)

  7. What a great idea! Certainly a great part of free software is to leverage and reuse what is available (even if it’s not entirely free).

    I have to say though, while I understand the flow of naming from silverlight to moonlight to moonshine, if you picture yourself in front of a group of (non-technical) end users or executives and tell them to use moonshine, could you do it with a straight face and expect the same? (ie… we need a free software marketing centre to support some branding exercises)

  8. Aaron this is fantastic! Thanks for working on this. Things like playing WMV files and evo properly connecting to exchange (thanks openchange) are making Linux fit well with “the other big operating system”. It also

  9. I have to agree with Michael in #6. I moved away from Firefox to Epiphany and it looks like Moonshine is useless to me. I seem to be having trouble getting it installed in Firefox (both from the Ubuntu repo and my old install from Mozilla’s tarball) although I finally got it working in my old Fx install. This really needs to be easier to install and it would be great if non-Firefox users (Opera, Epiphany, etc) were able to enjoy Moonshine. Otherwise it’s as bad a sites that require Silverlight 2 which is flat out MIA for Linux users. For now.

  10. Well, the answer will probably be no, but I can try anyway:

    Does/will this support DRM? I know, DRM is an OMGEVIL thing, but some live streams make use of this anyway.

  11. This is awesome.

    But why not make Moonshine work by default firstly trying to locate a native codec and if it fails, try to locate it from MS? This way it could be bundled by default in openSUSE/whatever-distro instead of the Totem one.

  12. @Patrys: no idea why it isn’t working, but I will look into it. This was just a first public release, so I’m sure there are bugs that will need ironing out. Thanks for the test link.

    @mike: Moonshine is under the MIT X11 open source license.

    @BostonPeng: as I replied to Michael, it is a goal to get Moonshine working in other browsers. It should not be difficult, it was just not a primary focus for the first release.

    @Sander: Moonshine simply turns into Moonlight, the official Silverlight player for Linux. If Microsoft ever provides a DRM solution for Moonlight, then it is likely that it would work in Moonshine. There’s no telling what that could mean though (e.g. what kind of DRM).

    @antimonio: I’m not sure what you mean, but the entire point of Moonshine is to translate into a Silverlight application. You really can’t get much more “native” than the Moonlight WM codec. It’s a port of Microsoft’s WM decoder to Linux. It’s native C code, and it’s the actual decoder from Microsoft. It is a free and painless download from inside Moonlight. If you want to use your GStreamer (what I am guessing you are calling “native” codecs), then use Totem.

  13. As “native” I mean the one installed in the system if there’s one (for example, from Packman). This way you would target every kind of user: the ones that want to remain with non-MS codecs but without messing with the (sometimes buggy) Totem plugin, and the ones that prefer a full-official codec experience.

  14. @Livo: try clicking on the black player area and pressing the space bar. I think there might be a bug when the tag tells Moonshine to hide controls and also to auto-start the video. Please let me know if pressing space (which toggles playback) helps. Also, a link to the content in question would help.

  15. Hi, im on Fedora F10 x86_64 and it’s not working. Installing Moonlight and Moonshine both work fine, but installing the codec pack crashes the browser near the end of downloading the pack. Restarting the browser and going to any website using silverlight will crash the browser now.

    Is this codecpack 64bit capable?

    Funny, as soon as you install somethig from Microsoft things start crashing. ;)

  16. @antimonio: that isn’t a decision that moonshine can make – it’s a requirement of the moonlight plugin that we don’t ship the binaries with support for ffmpeg/whatever codecs. You can rebuild moonlight from scratch to use ffmpeg (although this might still not use the codecs you’re looking for it to use), and moonshine will automatically use that.

  17. Chris: thanks for your comment.

    Then, why not make Moonshine not use Moonlight when it encounters valid local codecs? I know that then it would use a totally different technology and it may be like embedding banshee on a Firefox plugin, but wouldn’t that be really neat? This way we forget about Totem (I really like some Totem features, but I very much prefer the Mono platform than the python one…).

  18. Moonshine supports full screen, but it’s up to the web site embedding the control to decide if the tool bar will be shown that has the full screen button. You can always turn on full screen by pressing the “F” key after clicking on the video display though.

  19. Excellent work. Thank you. I did some quick testing and decided that fluendo’s decoders are much more optimized than Microsoft’s Media Pack, but this is a great alternative to those who aren’t interested in buying them.

    I did notice that the standalone player doesn’t seem to support widescreen videos properly, at least on the 3 I tried.

  20. Wade, your testing is likely flawed. It is very likely that the performance you are seeing is not due to the codecs, but the rendering layer. With GStreamer you can use the XVideo extension because no in-scene compositing needs to occur. In Moonlight, XVideo is not an option, because other elements may have to blend with or manipulate the video texture.

    That is to say, a lot of optimization work needs to occur in Moonlight, yes, but blaming the codec implementation is not the right thing to do.

    As for wide screen, I have done a lot of testing against the WMV HD reference content gallery, which are all wide screen videos and everything has been behaving as expected. Any chance you could link me to the offending content?

  21. A troll on my blog posting comments claiming that I follow “Microsoft’s FUD campaign” and that Moonlight and Moonshine are not FOSS (which are LGPL and MIT X11 respectively, and wherein installing the Microsoft Media Pack/codecs is entirely optional and never forced on the user) insists I am deleting his comments. I am not. I just will not approve his misinformation, and, well FUD. I am highly amused though.

  22. IIRC, Netflix uses Silverlight directly, not embedded Windows Media, so Moonlight will have to support that directly, which won’t happen until the 2.0 release at least. So stay tuned, the future is promising in this regard, but it really has nothing to do with Moonshine.

  23. @Livio: this is a “bug” in Moonlight due to the way it handles ASX playlists. Basically the parser is too strict, and the site you are trying to use has some bad ASX elements and Moonlight refuses to play it. This will be fixed soon with the next Moonlight release. We’ve added a not-strict mode in Moonlight for Moonshine. By default Moonlight is strict to be feature-and-bug on-par with Silverlight. Thanks for the test data!

  24. I don’t think I’m a troll, my legitimate (and only) question was about the MMP license. When it was announced Miguel said “The codecs will be binary codecs, and they will only be licensed for use with Moonlight on a web browser (sorry, those are the rules for the Media codecs[1]).”

  25. I guess from what I’m seeing here that my system is unique in its failure mode:

    I’m running Suse 11.1 64-bit with Firefox 3.0.5.

    Moonlight and Moonshine seem to install just fine. If I run Firefox and go to the C-Span site, I get the codec installation prompt. I agree to the terms, the download bar moves across, and then I get a “permission denied” message.

    If I run Firefox as root, the codec installation works, but the codecs are apparently not visible to my regular user account as the download prompt reappears.

  26. Hello Aaron

    Great work, but I have the same problem as Livio (both OpenSUSE 11.0 and 11.1). Blank box everywhere. I am not sure I understood your advice at @40.
    What can I do to fix the problem? Build Moonlight from svn with some parameters?

  27. Doesn’t work for me on Ubuntu 8.10 (32 bit)

    The Websites are just blank where the video should be.
    Is there any kind of upport forum or bug tracker?

  28. Moonshine will have a more useful web site launched next week, and we’ll have a bug tracker. For now, here are the basic requirements for Moonshine working, so please follow them carefully:

    a) Firefox 3.0
    b) Moonlight 1.0
    c) Uninstall (just disabling through Tools->Add ons->Plugins is not enough, due to a bug in Firefox) any media player plugins that might claim support for Windows Media mime types (verify through about:plugins).
    d) Install Moonshine 0.2. Verify that both Moonshine and Moonlight show up in about:plugins.
    e) Run Firefox like this from a terminal, after completely shutting down the Firefox process: “firefox -P default -no-remote” – navigate to the C-SPAN link on the Moonlight site, and verify based on the console output that the Moonshine plugin loads to handle the content, and that in turn Moonshine is able to load Moonlight (you should see some messages about NP_Initialize and NPP_New)

    Comments on the blog are getting a bit out of hand for me to be able to keep track of. The next release should fix a few known bugs so far, and we’ll have a better project infrastructure up to help handle bugs.

    Thanks everyone for your help in testing the first release of Moonshine – your feedback has already allowed us to fix a number of issues and increase compatibility – and I look forward to your feedback on the next release.

  29. Thanks for reply, but this is not working for me neither (no moonshine loading in console, just moonlight)
    I am very much looking forward for the next release.

  30. For now, here are the basic requirements for Moonshine working, so please follow them carefully:

    > a) Firefox 3.0

    Vanilla 3.0.6 (I’m using it because of Mozilla’s crash reporter availibility)

    > b) Moonlight 1.0

    Got it.

    > c) Uninstall (just disabling through Tools->Add ons->Plugins is not enough, due to a bug in Firefox) any media player plugins that might claim support for Windows Media mime types (verify through about:plugins).

    I moved out of my Firefox’ plugins directory. Nothing has changed.

    > d) Install Moonshine 0.2. Verify that both Moonshine and Moonlight show up in about:plugins.

    They show up.

    > “firefox -P default -no-remote” – navigate to the C-SPAN link on the Moonlight site

    ** (firefox-bin:10617): DEBUG: libmoonmp-plugin: Loaded Moonlight plugin: /home/livio/.mozilla/firefox/r8hzy2hf.default/extensions/
    ** (firefox-bin:10617): DEBUG: libmoonmp-plugin: NP_Initialize (0xb7f8ca60, 0xbfbe7b34)

    (firefox-bin:10617): Moonlight-WARNING **: Forcing client-side rendering because we detected binary drivers which are know to suffer performance problems.
    ** (firefox-bin:10617): DEBUG: libmoonmp-plugin: NPP_New

    I still get a black square.

    > and we’ll have a better project infrastructure up to help handle bugs.

    I hope so. Comments are not comfortable way of reporting bugs and problems ;) .

  31. ehmm, sometimes I have no controls in Moonshine.

    Probably because the website disables them? But that really sucks. I wanna be in control ;)

    Is there a shortcut for fullscreen?

Comments are closed.