[vlc-devel] [Paul ROUGET <paul.rouget at no-log.org>] VLC MediaControl and Mozilla Plugin

System administration admin at via.ecp.fr
Tue Jun 6 19:25:15 CEST 2006

----- Forwarded message from Paul ROUGET <paul.rouget at no-log.org> -----

From: Paul ROUGET <paul.rouget at no-log.org>
Date: Tue, 06 Jun 2006 00:59:10 +0200
To: vlc-devel at videolan.org
Subject: VLC MediaControl and Mozilla Plugin
User-Agent: Thunderbird (X11/20060516)
X-Spam-Status: No, score=-4.7 required=5.0 tests=FORGED_RCVD_HELO,
	UNIFIED_PATCH,UPPERCASE_25_50 autolearn=failed version=3.0.3

The deleted attachment is at:
I've done some work around the VLC Mozilla plugin in order to make the 
MediaControl API
avaible from JavaScript.

  You can find a sample JS code at the end of this mail.

  This is an early draft. It's buggy. I don't know if it works under 
Take a look at the new vlcintf.idl to understand how to use the 
mediaControl API.

Some points:
  - I've implemented a nsIException in order to throw mediaControl 
  - Some methods are not implemented because they're just not not 
implemented on the VLC side (like get/set_fullscreen).
  - I force the return of a nsISupport object instead a NPObject (cf. 
  - Why not put the argv of VLC in a <embed>  attribute ? (cf. FIXME 7 & 8)
  - I didn't succeed to make a new library dedicated to this binding (I 
don't know well autotools), so I build this code in the plugin library.
  In order to make this component registrable by Mozilla, the code must 
be in the components directory. The plugin code has to be
  in the plugins directory, so you have to link or copy the plugin 
library (wich embed the binding code) in the components directory of 
  Yes, I know, it's terribly ugly :)

  Some notes about security:
  This code is as able as a XPCom component, so is not accessible 
without any chrome priviledge by default. The component implements an 
named nsISecurityCheckedComponent, it provides the permission for this 
component to be used in a classic web page, so there's some security
issue (for example, currently, you can use the snapshot method and save 
a picture where you want in the disk, and that with a simple JS code). I 
the mediaControl object should be accessible only if it's explicitely 
specified in the pref file (pref.js). (cf. FIXME 1 & 2 & 5)

  This patch works fine under Linux with VLC 0.8.5.

Ok, I hope you'll like this code and I'm really sorry for my poor English :)


var vlc = null;
var mc = null;
var pos1;
var pos2;

function foobar() {
	try {
		vlc = document.getElementById("vlc");
		mc = vlc.getMediaControl();

		var pos1 = mc.createPosition();
		pos1.key = pos1.MEDIA_TIME;
		pos1.origin= pos1.ABSOLUTE_POSITION;
		pos1.value = 0;

		var pos2 = mc.createPosition();
		pos2.key = pos2.MEDIA_TIME;
		pos2.origin= pos2.ABSOLUTE_POSITION;
		pos2.value = 10000;

		setTimeout(js_render_text, 1000);
	} catch(e) {alert(e);}

function js_playlist() {
         try {
                 var aPl = mc.playlist();
                 var size = aPl.size();
                 var i = 0;
                 for (i = 0; i < size; i++) {
         } catch(e) {alert(e);}

function js_snapshot() {
         try {
                 var aImg = mc.snapshot(pos2);
         } catch(e) {alert(e);}

function js_render_text() {
         try {
                 mc.render_text("Foobar", pos1, pos2);
         } catch(e) {alert(e);}



http://www.xulfr.org - Technologies Mozilla

----- End forwarded message -----

System administration <admin at via.ecp.fr>
VIA, École Centrale Paris, France

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html

More information about the vlc-devel mailing list