This page as PDF

SrtOrganizr milestone – VLC integration in XUL app

Here we are, September 15th. First Milestone of the MMTC course project. And I have to say that a part of the project which scared me is done! Yes, I succeed integrating VLC inside my XUL application.

The documentation

I refered to the online documentation of VLC for developers. There are many ways to embed VLC in your application. Basicaly there are 3 main solutions :
-libVLC
-mediaControlAPI
-Javascript API (Mozilla plugin)

After reading the documentation of the two first ones, I was so afraid that I can’t find an effective solution that I decided to give a try to the JavaScript API.

The code

So here is the code to embed : as the “embed” element is a part of the HTML namespace, we have to define it in our code.

<window id="main" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&title;" style="width: 700px; height: 500px;"
persist="screenX screenY width height sizemode">

Then we can include the following piece of code, which is the Mozilla VLC plugin :

<html:embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2"
width="640"
height="480"
target="file://C:\video.avi"
id="vlc">
</html:embed>

And…here we go! We can now play with the JavaScript API!

var VLCUtils={
openFile : function(){
var vlc = top.document.getElementById("vlc");
var id = vlc.playlist.add("file:///C:/video.avi");
//alert(vlc.versionInfo());
vlc.playlist.playItem(id);
}
};

The most difficult part, the one which made me waste like 2 hours, was to find the good path…and the good format! (“file://” ok let’s try “file:\\\C:/”…). But I think there will be some other problems to fix, like the path (windows/linux/mac), or the fact that the user may not have the Mozilla VLC plugin.

And then?

Now, I have to include a file browser, so I can manage the files, and play it in the embedded VLC player to check if the subtitle file is the good one.

So the good news are that the project is on his way, but the bad news are…I’m currently looking for a job, as you may already know, and I don’t have as much time as I planed to.

See you soon!

  1. No comments yet.

  1. No trackbacks yet.