Unable to play media with vlc ocx

2019-07-09 20:16发布

I want to embed the vlc media player in a .NET application I've found a lot of solutions

  1. VLC .Net interface <- didn't work with me
  2. wrappers for dll functions <>
  3. http://vlcdotnet.codeplex.com this is nice
  4. the activex of VLC - i really liked to use it it must be less bugs and errors but errors found

I found 2 controls "VLC ActiveX plugin and IE web plugin v1" , "VLC ActiveX plugin and IE web plugin v2" What is the difference between them?? i dragged and dropped the fist one and used the following code

axVLCPlugin1.addTarget(@"D:\video\English\10,000.b.c\10000bc.rmvb", null, AXVLC.VLCPlaylistMode.VLCPlayListAppendAndGo, -666);
axVLCPlugin1.play();

that had no effect i dragged and dropped the second one and used the following code

axVLCPlugin21.playlist.add(@"D:\video\English\10,000.b.c\10000bc.rmvb");
axVLCPlugin21.playlist.play();
//i also tried this
axVLCPlugin21.playlist.playItem(0);

also it had no effect

I didn't found many details and documentations of the VLC OCX what is the error ?

4条回答
Fickle 薄情
2楼-- · 2019-07-09 20:35

The plugin (v1 and v2) works fine in c#.net. v2 is better.

You need to use "file:///" before the link:

axVLCPlugin1.addTarget(@"file:///D:\video\English\10,000.b.c\10000bc.rmvb", null, AXVLC.VLCPlaylistMode.VLCPlayListAppendAndGo, -666);
查看更多
戒情不戒烟
3楼-- · 2019-07-09 20:48

It might be the file format. I also tried to use these two ActiveX controls to play media files in a MFC application. It worked with .avi and mp3 format, did not work with mp4 format. And if I remember it correctly, VLC does not have the codecs for .rmvb format in itself by default because of some copyright problem.

查看更多
做自己的国王
4楼-- · 2019-07-09 20:52

The solution is simple: you need an uri, not a normal path

This:

var uri = new Uri(@"D:\video\English\10,000.b.c\10000bc.rmvb");
var converted = uri.AbsoluteUri;
axVLCPlugin21.playlist.add(converted);

There you go.

查看更多
对你真心纯属浪费
5楼-- · 2019-07-09 20:54

The v1 of the ActiveX is deprecated and v2 is primarily for browser integration thus not intended to be used like you tried...

Use http://vlcdotnet.codeplex.com/ - this is a well-working library...

查看更多
登录 后发表回答