Using the VLC ActiveX control

This forum is about all development around libVLC.
DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Using the VLC ActiveX control

Postby DukeNukem » 28 Jul 2009 22:41

Hi,

Hope this is the right section.

I'm trying to find out how to use the ActiveX control for VLC but can not find any documentation or examples on how to open a file and play it. I've added it to both C# forms and MFC dialogs but thats about it, a black panel on a window.

E.g. c# :-

Code: Select all

private void Form1_Load(object sender, EventArgs e) { string[] tryThese = new string[] { @"C:\\Delme4.mp4", @"Delme4.mp4", @"http://localhost/C:\\Delme4.mp4", @"http://localhost/Delme4.mp4", @"file:///C:/delme4.mp4", @"file://C:/delme4.mp4", @"file:/C:/delme4.mp4", @"file:///C:\delme4.mp4", @"file://C:\delme4.mp4", @"file:/C:\delme4.mp4", }; axVLCPlugin21.playlist.clear(); int iAttempt = 0; while (axVLCPlugin21.playlist.items.count == 0 && (iAttempt < tryThese.Length)) { Debug.WriteLine("Trying (in vain) " + tryThese[iAttempt]); axVLCPlugin21.playlist.add(tryThese[iAttempt], null, null); iAttempt++; } if (axVLCPlugin21.playlist.items.count == 0) MessageBox.Show("VLC Bug ;-)"); else axVLCPlugin21.playlist.playItem(0); }
The only example I've found was http://trac.handbrake.fr/browser/trunk/ ... s?rev=2036 but this doesn't give _exactly_ the string to supply when adding to the playlist.

So, exactly what code do I need to open a file and play it ? Once that far I'm sure I can work out the rest, but not being able to open a file in the first place is a bit of a killer :(

TTFN,
Jon

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 29 Jul 2009 22:37

I know there is a .NET wrapper for LibVlc, but it is overkill for me as I want to open file, play file, maybe set position and really thats about it. As VLC seems to use some libraries also used by Ffmpeg, I'm hoping to incorporate into an app a facility to preview an video file via a VLC control prior to launching ffmpeg to do a conversion. An example of such usage would be to allow the user to locate a section of video within a video file and then use ffmpeg to convert just that portion of the video.

So, is there really no way to utilise the ActiveX control in Windows applications ?

TTFN,
Jon

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: Using the VLC ActiveX control

Postby XilasZ » 29 Jul 2009 23:25

I don't know about the activex, but you should take a look at kairos's wrapper here : viewtopic.php?f=32&t=52021

The first post contains a link to the sources. There is also a sample with a simple player with the wrapper.
The wrapper may be too much for what you need, but it can show you how to deal with libvlc directly.

You can look at what it does and how it works, or just simply use it, it's easy to use (i think :p).

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 30 Jul 2009 09:55

I initially looked at the library but have not got it to run yet - it expects to find functions in the DLL that aren't there. OK, some kind of VLC version - thought I had a pretty recent version, obviously not, sure I can sort it.

There are two ActiveX controls. The first one looks a bit awkward but the second one is a lot cleaner. Someone/a group have clearly put some thought into the MkII control, and if I simply drop the control on a form all the necessary interface code is auto-generated. There is a playlist interface for adding a media source and another with Play() so in theory three lines of coding and I have me a player ! Awefully tempting me thinks.

I'm planning to release the application as open source (http://forum.doom9.org/showthread.php?t=146727&page=2, handle= 'JonE') and there is some advantage to minimising the number of external libraries.

Basically there are certain video formats that are painfully slow / inaccurate for general seeking within a video, something you use a lot in an editor, so I could simply offer the user the option to transcode to a better format using ffmpeg. However, they won't be happy if they have to transcode a potentially very long clip which takes an hour when they just wanted, say, a two minute sections, hence using VLC to preview the video so they can set start and end points, with the advantage VLC should recognise everything that ffmpeg can.

TTFN,
Jon

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: Using the VLC ActiveX control

Postby thannoy » 30 Jul 2009 11:46

Speaking about the ActiveX itself, you will find its API on Documentation:WebPlugin wiki page.

Adding a stream is roughly like this (JavaScript syntax):

Code: Select all

.playlist.add(url, fooname, options);
Where fooname and options can be null, and where option is either a string[] or a string like ":no-video-title-show :anotherOption=foo"

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 30 Jul 2009 14:18

Thanks Thannoy,

Is it possible you could post exactly what I need to pass to the 'Add' function so as to load file "C:\Delme4.mp4" ? In the example I posted you can see I tried a load of different ways and none worked, including several versions of one of them described in the wiki ("[file://]filename") but none of them worked. Incidently the VLC player application opens and plays the file without any problems.

I also hooked into the logging feature of the control but it doesn't log any messages to do with why a file is being rejected :(

TTFN,
Jon

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: Using the VLC ActiveX control

Postby thannoy » 30 Jul 2009 16:45

I would try:

Code: Select all

axVLCPlugin21..playlist.add("C:\\Delme4.mp4", null, null); axVLCPlugin21..playlist.play();
or

Code: Select all

id = axVLCPlugin21..playlist.add("C:\\Delme4.mp4", null, null); axVLCPlugin21..playlist.playItem(id);
But it is equivalent to your test I think. So maybe try without null values :):

Code: Select all

axVLCPlugin21..playlist.add("C:\\Delme4.mp4", "fooname", ":no-video-title-show"); axVLCPlugin21..playlist.play();

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 30 Jul 2009 22:44

Thanks, you confirmed I've got the right string - and direction of slash chars is important :oops:

But, its left a different problem. It now adds the MP4 to the playlist but still refuses to play it, despite being perfectly playable in the VLC application. So I've tried another file, this time an MPEG2 file ..and it worked :D ... almost ... it plays the file but closing the application causes an immediate system reboot .

I've made sure I've stopped playback and emptied the playlist prior to the app closing but still get instant system reboot.

TTFN,
Jon

kryptonite
Blank Cone
Blank Cone
Posts: 52
Joined: 22 May 2009 12:01

Re: Using the VLC ActiveX control

Postby kryptonite » 31 Jul 2009 08:12

But, its left a different problem. It now adds the MP4 to the playlist but still refuses to play it, despite being perfectly playable in the VLC application. So I've tried another file, this time an MPEG2 file ..and it worked
I had a similar problem, where I could play certain formats, but not others - seemed like the required plugins were not found.
Have you set the --plugin-path correctly? Also, this option didn't work fine in 0.9.6. I guess you must be using the latest release though.

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 31 Jul 2009 09:48

Have you set the --plugin-path correctly?
Nope, wasn't aware I needed to for the ActiveX control. Now tried it on my machine at work (Vista :( ) and the ActiveX control fails to open anything at all. I've tried adding the following to strings as the thire parameter to the playlist.add() method :-

Code: Select all

@"--plugin-path=""C:\Program Files\VideoLAN\VLC\plugins"""

Code: Select all

@"--plugin-path=C:\Program Files\VideoLAN\VLC\plugins"
but still no joy.

However this plug-in path probably explains why the .NET wrapper code failed to work when I tried it - I copied all the DLL's from the main VLC directory into the .NET project's bin\debug directory but totally overlooked the plugins sub-directory and the sample projects refused to play anything ... DOH!

TTFN,
Jon

PS : Work (V*st*) machine is using version "0.9.2 Grishenko"

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: Using the VLC ActiveX control

Postby thannoy » 31 Jul 2009 10:25

For the reboot. As you may know LC can't do such things itself. It is more probably a driver which dies at the time VLC stop feeding it.

Have you tried to do this kind of job in a on_close() procedure of your program:

Code: Select all

.playlist.stop(); sleep(600ms) // ready to exit

kryptonite
Blank Cone
Blank Cone
Posts: 52
Joined: 22 May 2009 12:01

Re: Using the VLC ActiveX control

Postby kryptonite » 31 Jul 2009 10:31

I haven't used the ActiveX version, so I don't know the framework you're using. I have a Java based implementation.
But the --plugin-path option should be provided as one of the args when creating the libvlc instance, and you need to give doubles-slashes:

Code: Select all

--plugin-path=C:\\Program Files\\VideoLAN\\VLC
0.9.2!? From the development point of view, you should consider upgrading

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: Using the VLC ActiveX control

Postby thannoy » 31 Jul 2009 10:41

The ActiveX itself send the --plugin-path to libvlc_new when it loads. ActiveX users can not alter this behavior.

Argument of plugin-path is based on windows registry. A key is added in it during VLC setup to know where it is installed. So path given here is VLC based folder + "\plugins".

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 31 Jul 2009 13:27

@Thannoy :

The sleep() call is a good thing to check - will try it tonight. However the PC is several years old and has been very reliable; it gets used for a lot of video work (as well as the occasional game) without a hint of trouble, and VLC player itself has always behaved faultlessly, so I'm reluctant to fiddle with any drivers at this stage.

I did expect the ActiveX control to know where it is located (and hence location of plugins), but I was starting to get desperate ! However, whilst investigating the ActiveX version I couldn't seem to find any events related to the VLC bit (such as playback completion) which, I guess, means "stop messing about and use the .NET wrapper".

I shall re-visit the .NET framework in anger tonight. Done a quick test at work (whilst no-one was looking :D ) and simply set the project's output dir to the main VLC directory and the player sample now works. (The VlcMediaPlayer.Sample does throw an exception as soon as my test video gets to the end of short (as in seconds) long video but this is due to error in progress position which I think should be in range 0..1 but at the end of the short test video is giving a position of 1.0625).

Anyhow, as for the final application I'm developing, it would be a Bad Idea to put the version of the .NET wrapper I'm using in the main VLC directory, so I guess during installation I should copy the main VLC files from the main VLC directory to wherever the wrapper dll ends up but point to the original plugins directory (picked up via the registry) ?

@kryptonite :

The ActiveX version is (in theory!) straightforward, you simply drop the control onto a (.NET) form and all the interface code you need is automatically generated for you to interface to the object.In theory it really is just three lines of code you need to play a video file - if it worked.

You can drop it on an MFC dialog and that kinda works, though it doesn't auto-generate a lot of the interfaces.

Yes, must update to later version at w*rk ! However the ActiveX control (V2) only needs > V0.8.6 or thereabouts according to the Wiki.

TTFN,
Jon

thannoy
Big Cone-huna
Big Cone-huna
Posts: 601
Joined: 20 Mar 2008 09:44
VLC version: 0.9.8a & 1.0-git
Operating System: GNU/Linux Fedora10
Location: France
Contact:

Re: Using the VLC ActiveX control

Postby thannoy » 31 Jul 2009 14:06

If VLC is installed by its setup, registery should be good and ActiveX ready to use with the good plugin-path.

DukeNukem
New Cone
New Cone
Posts: 9
Joined: 28 Jul 2009 22:30

Re: Using the VLC ActiveX control

Postby DukeNukem » 02 Aug 2009 09:21

After upgrading to the latest version 1.0.1 of VLC I thought the pc-reboot was gone, however it seems to have moved to where the video reaches the end of playback; if you close fairly quickly its ok but if you leave it there and touch nothing it reboots after maybe 5 seconds. However, since the .NET wrapper does look more useful than the ActiveX version I think I'll drop the ActiveX idea.

There is however a bug, not sure if its libVlc itself or the .NET wrapper, just like the newish Vista machine at work, my old XP machine at home also suffered exceptions during playback, traced to wacky values being passed to the position slider. Tracing back further the root cause of this seems to be the position changed event as recieved from VLC is getting IntPtr data of 0, presumably meaning null. I also have an issue with the playlist sample which has deadlocked on a call to libVlc a couple of times but not investigated further as yet.

The .NET project indicates version 1.0.0 and I'm using VLC version 1.0.1 I do hope this doesn't mean that a change has been made in this area :?:

TTFN,
Jon


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 42 guests