XUL and XULRunner (co-starring flash)

home page Like you probably noteiced I got more and more interest in XUL and experimenting Firefox extensions in the last days.
After my first extension I decided to try something different and first I created a little (this time nothing new at all) and lightweight extension for grabbing flv videos while visiting youtube.com or video.google.com. It simply creates a statusbar icon and when there are availables flv on the page it will get active. Clicking on it let you save the current playing flv. You can also change the options and tell the extension to open the video using you favourite Video Player (Like VLC or FLVPlayer)

home page Install the getvideo-0.1-fx.xpi Firefox extension

see When I did this extension comes also in my mind the idea of creating a simple Flash video player, just for practice. I was doing it using python/wxPython as usual.. but then I wanted to try using XUL  and package it with XULRunner (a runtime XUL runner, which runs xul applications like standalone applications).
First of all I have to say thanks to Darron Schall for his article on how-to embed swf files in xul. I was going crazy to understand all the steps for creating a valid xulrunner package..
As usual opensource sofware has bad and incomplete documentation. I need to look into one of the examples (chatzilla) to understand how it works.

Once I undertood that a new problem arise, the damn flash security sandbox error! When the xulrunner application starts it prompt also the security warning.. Oh my god!

After various attempts and after reading various articles on FlashplayerTrust I managed to solve the problem (or at least I think I’ve solved…).
In the installer a file named follow site flvideoplayer.cfg will be copied inside the Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust direcory, and it’s content is

here chrome:\\flvideoplayer\content\flvideoplayer.xul

hire someone to write my business plan In this way the embed swf file should has the correct permissions to communicate with the xul page using fscommand. I thought that my experiment was finished, but when I shown it to a friend he  asked me to add also the possibility to convert the .flv video into other formats (avi, mpeg, etc).
Well, fortunately there’s ffmpeg which does this job for everyone 🙂

Thus I included ffmpeg to enable video conversion. What I did it’s a runtime .bat file which wil invoke ffmpeg:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function execute_batch(bat) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
try
{
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(bat.path);
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(file);
process.run(true, {}, 0);
} catch(e)
{
alert(e);
}
}

link Ok, how to install this application.
In order to run correctly this application you first have to:

  • download XULRunner (I did not included in the installer because it’s about 10Mb).
  • Once downloaded from a command prompt, run http://www.you-select.nl/?help-with-university-essays xulrunner.exe –register-global (to register for all users) or source site xulrunner.exe –register-user (to register for one user only).
  • To enable the flash plugin (the Firefox plugin isn’t used, so if you launch the application you won’t see the flash embed object) you have to copy:
    {programs}\Mozilla Firefox\plugins\NPSWF32.dll
    {programs}\Mozilla Firefox\plugins\flashplayer.xpt

    into your XULRunner\plugins\ folder
  • Now just download yougrab! and install it.

Install YouGrab! (sorry but currently Windows only)

  • Federico Bebber

    Great work as always!!!

  • Hi. great idea. That xulrunner seemed very interesting and i wanted to see it in action. However once installed, running “yougrab” does nothing at all. ?

  • that’s strange. Did you registered xulrunner as described? If correctly installed xulrunner you should find a key in the windows registry
    mozilla.org\GRE\1.8.0.4\GreHome
    corresponding to the path of your xulrunner.exe. Try also to launch yougrab from a command prompt (inside the yougrab installation dir):
    xulrunner application.ini

  • Max

    Hi,
    Is there any chance you could modify GetVideo to support other video sites, such as DailyMotion.com?

  • Hi,
    Thanks for this nice article, Is it posible that you can tell me how i can make a installer from a xulrunner application and how to make the .exe to startup the application ?

  • Alessandro Crugnola

    You can create the .exe using:

    xulrunner --install-app appName.zip outputdir

    for the installer you can use any of the free installers such as NSIS or InnoSetup

  • Xypher

    Get Video has stopped working with DailyMotion. Please can you fix this?
    Thank You!

  • jordan

    no matter what i do, i went through all the right step, along with someone that got getvideo to work, but no matter what i do, when i click on the icon while viewing a video on youtube it says “no video available” what am i doing wrong?

  • jordan

    so it works fine on google but not youtube, it says no video available…what can i do? is there a conflict with youtube i should know about? im on a mac. thanks

  • jordan

    soooo…now if i switch to google video first, then go to youtube, it says i have a video available.
    but then when i go to save it to disk, a blank popup download window comes up, and theres a blank getvideo file on my desk top. i switch it to an .flv file and still it wont open…whats going on? please help.

  • adam

    ive download the get video application from the firefox website. Have been on to youtube, but cant see a way to download the any video from that site.
    What am i doing wrong?
    Thanks

  • dougi

    Hi,
    I have to make work flash with xul. the only problem i hav come from the flash player security alert.
    – How do u do to copy a .cfg file during the installatation of the plugin in the flash player trust directory ?
    – I have tried to put as u say the xul file (chrome://) in the .cfg file and it does not work , i have to write the windows path.
    Thanks for your help.

  • Mark

    Hi,
    Where can I get the source code?
    Thanks

  • dougi

    Hi,
    Thank you for this example but i have somme questions.
    I need to insert a swf into my extension but like you of course, i ‘ve got a problem with the security sandbox.
    How do u do to copy a file during the installation of the xpi extension into the flasplayertrush directory ?
    For my test, i have manually copied the .cfg file into the right place and it only works if i put the entirely windows path of my extension and not the chrome uri of my xul container like in your example?
    Can u help me ?
    Thanks in advance.

  • Mark

    I have the following problems:
    1) When run the executable, only local (file://) flv files can be loaded. Attempting to load any other URI (e.g. http) fails)
    2) When using xulrunner.exe application.ini, not even local flv are loaded
    My configuracion: XP SP 2
    Xulrunner 1.8.0.4
    Could you verify?

  • hi,
    I’ve found this post very useful. I tried running this app on linux ( I copied and pasted the app folders from the installation location on windows) and tried running it using the latest xulrunner runtime (1.9.0.3). I altered application.ini to accommodate this.
    It appears to run fine (like my own test app) but these errors appear on the console:
    (Gecko:7883): GnomeUI-WARNING **: While connecting to session manager:
    Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed.
    (Gecko:7883): GLib-CRITICAL **: g_hash_table_unref: assertion `hash_table != NULL’ failed
    (Gecko:7883): GnomeUI-WARNING **: While connecting to session manager:
    Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed.
    (Gecko:7883): Gtk-CRITICAL **: gtk_widget_destroy: assertion `GTK_IS_WIDGET (widget)’ failed
    (Gecko:7883): GLib-CRITICAL **: g_hash_table_unref: assertion `hash_table != NULL’ failed
    if anyone has any ideas how to suppress/fix these please comment.
    thanks

  • Hi, Thank you for this example but i have somme questions. I need to insert a swf into my extension but like you of course, i ‘ve got a problem with the security sandbox. How do u do to copy a file during the installation of the xpi extension into the flasplayertrush directory ? For my test, i have manually copied the