PDA

View Full Version : Embedded VLC ActiveX control



theguywiththefunnyhair
April 12th, 2008, 02:36 AM
I was inspired by Marcel's work with putting movies and Live TV into his remote control. I thought it was a really good thing to be able to watch streaming media and not leave your skin, so i thought i might give it a go myself.

Getting the VLC ActiveX control embedded in a .html page was fairly easy and happened shortly after i managed to get my head around what it is ;).

I was thinking it would be a lot neater (and easier for me as i dont know js) if i could call methods on the control from .Lua instead of Java. I tried putting the ClassId value from the .html, for the GUID in value in the NR 'ActiveX component' dialoge box, after trying it a few different ways i was amazed to find when i stuck some curly brackets around it {} i actually had the thing showing up on my button in NR.

Now if i can just work out how to call a method on it i will be STOKED

I found a button in the action designer called 'Call ActiveX method' and i've been experimenting with it, the dialoge box for this button wants an input in the form [OBJNAME].[METHOD] just like that (including the brackets). I tried a few different things with it but couldnt get any response from the ActiveX control, and obviously i cant see how to get any return from my button. So i am wondering how this works, specific questions would be:

Is the OBJNAME an existing variable (Like the GUID maybe?) and if so where does it exist?
Do i need to include the brackets []?.
Where can i get the result (if any) of my method call.
Can i call a method on it from Lua? (please)


If anyone can answer any of those questions i would be very grateful.

mhwlng
April 12th, 2008, 03:27 AM
it won't work.

a complicated method like AddTarget can't (currently) be called from the active-x plugin :

from axvcl.idl file :

HRESULT addTarget([in] BSTR uri, [in] VARIANT options, [in] enum
VLCPlaylistMode mode, [in] int position);

in javascript :

var options = new Array(":input-repeat=1");
document.vlc.addTarget(targetURL, options, 4+8, -666);


only 'simple' methods are currently supported...

Marcel

Rob H
April 12th, 2008, 11:08 AM
To be honest I have no idea - if you have a sample CCF (the simpler the better) I'll give it a go here.

Rob H
April 12th, 2008, 11:16 AM
I've had a look at this in a bit more depth and there is code to call a method and get and set properties from Lua, but the method that opens that library has been commented out - presumably there is a problem with it. I'll see what I can do though given a sample CCF.

theguywiththefunnyhair
April 12th, 2008, 03:20 PM
Hey Rob, its good of you to look at this now, you must be burning the candle at both ends!

You will need to install VLC with the ActiveX checkbox ticked before you try this. If you have an old version of VLC installed you might want to update it because the classID/GUID string changed. Windows installers etc are here http://www.videolan.org/vlc/download-windows.html.

If you load the VLC_ActvX_Btn.ccf to NR you should see a button with a construction site style witches hat come up, this is a good indication its working!

According to this post http://forum.videolan.org/viewtopic.php?f=16&t=29654 on the VLC forums, the ActiveX plugin shares the same API as the mozilla plugin, so this document http://www.videolan.org/doc/play-howto/en/ch04.html should be useful as it lists all of the available calls for the mozilla plug. Scroll down to the last part under the heading 'Build HTML pages that use the plugin (version > 0.8.5.1)'.

If you want to see the thing working in NR via a web browser component i have also included the .ccf i used to test that with the .html file that helps it. You will need to edit the initial URL of the web browser component in the .ccf and the hardcoded path to the media file in the html if you want it to work, the path to the media is in the first <INPUT> tag.

Dont forget that with current (.117) version of NR you need to restart NR to see any changes made to the 'initial URL' in NRD

good luck!

Rob H
April 13th, 2008, 01:29 AM
Thanks - I can't promise when I'll be able to get around to this.

theguywiththefunnyhair
April 15th, 2008, 02:39 AM
Thanks - I can't promise when I'll be able to get around to this.

No worries Rob, i know you guys are all very busy at the moment.

So for now i will follow Marcel down the VLC embedded in .lhtml and controlled with javascript method. My first attempt at getting this to work while trying to maintain the look and feel of my skin has me trying to write the js script from Lua eg;
<% if NetRemote.GetVariable('Video') =='play' then
msg = 'doGo();'
else
msg = 'doStop();'
end;
dofunc = '<script>\n'..msg..'\n</script>\n'
--NetRemote.SetVariable('html_peek',dofunc)
webserver:print(dofunc)
%>
In this example i was also trying to get a look at what the value of my variable was by setting an NR var.

As you may have guessed none of the above is doing what i wanted, so i must ask if this is possible to achieve, can i write js with lua and can i set NR vars from the lhtml?

mhwlng
April 15th, 2008, 03:43 AM
your code is only executed when the page is loaded.

you need a timer and then use the COM object in javascript to read an NR variable :

var ax = new ActiveXObject('NetRemote.App');
var s = ax.GetVariable("xxxx");



(I added my play/stop etc. buttons on the web page instead of on the NR panel, which makes it easier)

theguywiththefunnyhair
April 20th, 2008, 01:38 AM
I managed to get this working (thanks for the tip Marcel!) and integrated pretty well into NetRemote.

If anyone wants to give it a go this demo .ccf should make it easy to check it out on your pc.

Before it will work you will need to have VLC installed on your machine and you will also need to have checked 'ActiveX' when you installed it.

In order to make the file picker work on your system you will need a 'file path' set up in MediaBridge that has the root of your media files as its root, and you will need to know the name you gave this path. You also need to edit the .lua attached to the .ccf in a total of 3 places. the first two in the very beginning, change the values of
local vid_dir = 'I:\\TV'
local vid_gacroot = 'File Paths\\SP' to be the directory path to the root you set in MB and the name you gave to it, in my case the files are all in folders under 'I:\TV' and the File Path name i gave in MediaBridge was 'SP'. The other change you must make, is the same as the change you made to vid_gacroot only a bit further down the page
local fullpath = string.gsub(path, 'File Paths\\SP', vid_dir) I tried like hell to use the variable here but couldnt get the escapees together so ended up repeating the line :)

Copy the NetRemote directory to 'c:\Program Files' if you have a standard install or just copy the httpd folder inside it to your installed NetRemote directory. Open the EmbeddedVLC.ccf and away you go.

Its worth noting the slider bar was a PITA and is far from bulletproof, i would expect too much accuracy from it but for gentle use and large seeks it should do the job.

Rob H
April 20th, 2008, 09:48 AM
Made some small amount of progress - I think I'm adding something to the playlist (ie the playlist.itemcount goes up) but can't currently play it for some strange reason.

I'll keep trying tomorrow

Rob H
April 20th, 2008, 10:13 AM
Aha - got the wrong format for a file: URL - it works!!!

Odd that it increases playlist.itemcount even when the media isn't found

theguywiththefunnyhair
April 20th, 2008, 04:26 PM
you got it working with an embedded activeX component?

Rob H
April 21st, 2008, 12:14 AM
Yup, although it's a bit clunky ie you need to use something like


COM.CallMethod('VLC', 'playlist.add', fileURL)
COM.CallMethod('VLC', 'playlist.play')

I'd prefer to be able to acquire the VLC object and use something like vlc.playlist.add(fileUrl) but that's probably not going to happen anytime soon.

This should make it into build 120

mhwlng
April 21st, 2008, 01:56 AM
Hi Rob,

see earlier posts.

I think it's much more complicated :

I need to use the addTarget function which has an array with all the various options.

and also I read document.vlc.playing status

e.g. :



options = new Array(":input-repeat=1",
":file-caching=3000",
":mms-caching=3000",
":http-caching=3000",
//":vout-filter=deinterlace",
//":deinterlace-mode=x",
":aspect-ratio="+aspect,
":http-reconnect"
//,":no-overlay",":no-directx-3buffering"
);

if (vlc.Playing)
{
document.vlc.stop();
}

document.vlc.playlistClear();
document.vlc.addTarget(targetURL, options, 2, -666);



Marcel

Rob H
April 21st, 2008, 02:25 AM
I think that may be for VLC prior to 0.8.5.1 unless addTarget is an undocumented method?

There is another version of playlist.add that takes additional name and options parameters. Not sure what the options parameter is supposed to look like.

However, the above code works in NR builds after 119

theguywiththefunnyhair
April 21st, 2008, 04:07 AM
Your right about that being for a previous version of VLC.

Looking in the axvlc.dll under //VLC Playlist APIs i think that would now be:
//Add a playlist item.
function add(uri: BSTR; out name: Variant; out options: Variant): I4; stdcall;


just dont ask me what it means :)

Rob H
April 21st, 2008, 04:27 AM
Seems a bit weird using out parameters for the name and options! And, for that matter, name being a variant, unless that's to allow it to be optional?

mhwlng
April 21st, 2008, 08:50 AM
I think that may be for VLC prior to 0.8.5.1 unless addTarget is an undocumented method?


I don't know, but it works ok with the latest version of VLC...

Marcel

Rob H
April 21st, 2008, 10:18 AM
Strange. Perhaps it's a different GUID? Ah, in the examples they add version="VideoLAN.VLCPlugin.2" to the parameters of the embed tag.

mhwlng
April 21st, 2008, 11:16 AM
ok,

I used this :



<object classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8"
codebase="http://download.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"
width="<% return Marcel.vlc.tvwidth %>" height="<% return Marcel.vlc.tvheight %>" id="vlc" events="True">



Marcel

theguywiththefunnyhair
April 22nd, 2008, 02:41 AM
Hi Rob,
I tried the ActiveX component method with .120 but couldnt get much of a result. The code i used was
function MyFuncs.SendGo(nam)
local clr = COM.CallMethod('VLC', 'playlist.clear')
local add = COM.CallMethod('VLC', 'playlist.add', nam)
local play = COM.CallMethod('VLC', 'playlist.play')
print(clr,add,play,nam)
end and all i got was 'nil,nil,nil,I:\TV\dir\file.avi'

Rob H
April 22nd, 2008, 08:31 AM
Odd, thought I'd replied to this earlier!

You need to use a file: URL e.g. for I:\TV\dir\file.avi that would be


file:///I|\TV\dir\file.avi

pfeifer
March 20th, 2009, 04:16 AM
Hi All,

there are other method to be use for the controll?

For example I have this


CallMethod('VLC', 'playlist.play')

But I would use this



CallMethod('VLC', 'video.fullscreen',1)

May hel me?

Pfeifer

Rob H
March 20th, 2009, 04:34 AM
video.fullscreen is a property, so you would use the SetProperty and GetProperty methods on that. e.g.


SetProperty('VLC', 'video.fullscreen', 1)

pfeifer
March 20th, 2009, 05:24 AM
Works fine.
Thanks a lot.
Pfeifer

pfeifer
March 21st, 2009, 02:20 AM
Ohter 2 questions / problems:

First

I need to store the following value into a variable (it's the way for have the TV video stream from a Dreambox):

NetRemote.SetVariable('VLC3variabile','http://192.168.1.5:31339/0,0452,0202,028c')

if If write this value into a file video.m3u and use this code work


NetRemote.SetVariable('VLC3variabile','C:/video.m3u')

But probablly some caracters don't work in the variables management.

This work (IpCamera):

NetRemote.SetVariable('VLC3variabile','http://192.168.1.10/img/mjpeg.cgi')

Second problem:

How can set the "interlace" property of VLC?

Bye

Pfeifer

Rob H
March 21st, 2009, 07:13 AM
I can't see why the first wouldn't work, does it display the same way in NetRemote designer?

It looks like they don't expose an interlace property in the ActiveX I'm afraid, at least it isn't documented :(