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.

This entry was posted in uncategorized and tagged , , , , , , . Bookmark the permalink.

62 Responses to Announcing Moonshine, the project never formerly known as Pornilus

  1. Mephisto says:

    Nice work. Even though i prefer the totem plugin (its getting better with every release and doesnt need binary-only plugins from a party i don’t trust), this is excellent for my work laptop, which runs Redhat 5.3 and lacks seriously in multimedia support. Besides a minor issue with moonlight requiring, which wasnt available in the package manager, getting this plugin to work is a lot easier than compiling a recent totem, which depends on gnome, and uptodate gstreamer codocs and whatnot.

    However, in the URL posted above (, besides the issue already reported with video not autostarting, player controls do not show up for me. This is an issue with moonshine, since controls do show up with mplayer-plugin (even though mplayer doesnt seem to be able play the videos). I can start the video with spacebar, so the playback is at least working properly. Would be great if you can fix this. No way to control the video is a serious usability issue.

  2. Martin says:

    I had to edit file /usr/local/share/moonshine/application.ini to be able to run moonshine application because of “Error: Gecko MinVersion requirement not met”. I have firefox 3.0.6 installed. Video doesn’t work and I have the same problem as Livio I think. And that is what firefox says when I try to run C-SPAN:
    http-on-examine-response [Exception... "Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsIInterfaceRequestor.getInterface]” nsresult: “0×80004002 (NS_NOINTERFACE)” location: “JS frame :: file:///home/user/.mozilla/firefox/0ytz2vtp.default/extensions/%7B19503e42-ca3c-4c27-b1e2-9cdb2170ee34%7D/components/flashgotService.js :: anonymous :: line 2517″ data: no] —, video/x-ms-asf
    ** (firefox:370): DEBUG: libmoonmp-plugin: NPP_New

  3. Pingback: Anonymous

  4. Iain Cheyne says:

    I installed this and I still see the Totem plugin. How do I disable it?

  5. See the totem player uses w32codecs or FFMpeg implementation whixh does not support Windows media 9+ series completely … specially WMV screen … plugin … so this is an excellent option to use moonshine … and for totem to replace that will take hell lot of work by FFMpeg team to implement WMV 9 and up …. :)

  6. Livio says:

    Wow, and C-SPAN finally working.

  7. Roo says:

    Doesn’t install into Firefox 3.5. Any idea why or if there’s an update ?

  8. zekemx says:

    It seems this project is not being maintained.. The last question from Roo hasn’t been answered since July 1st 2009 and no update that works with firefox 3.5 has been released.

  9. zememx says:

    Too bad this plug-in is not yet released to work with firefox 3.5.3

  10. ST says:

    Will Moonshine be available for Firefox 3.6 ?

  11. Pingback: Moonshine

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>