VLC播放器无法播放任何视频。

9

我从COM组件中添加了VLC插件,拖到了我的表单上,为表单添加了两个按钮("播放"和"停止"),然后编写了以下代码:

private void Form1_Load(object sender, EventArgs e)
{
    axVLC.AutoPlay = false;
    axVLC.playlist.add(@"C:\Users\Hanif\Documents\Visual Studio 2010\Projects\Education Visualization\Vlc\Resources\Video1.wmv");
}

private void btnPlay_Click(object sender, EventArgs e)
{
    axVLC.playlist.play();
}

private void btnStop_Click(object sender, EventArgs e)
{
    axVLC.playlist.stop();
}

但是当我点击“播放”时,什么也没发生。我做错了什么吗?

相关:通过C#控制VLC - metadings
开启了抛出异常时中断吗?x32 构建与 x32 ActiveX 组件匹配吗?ActiveX 控件大小正确吗?有任何音频输出吗? - Brannon
3个回答

16

VLC插件是AxAXVLC.AxVLCPlugin2类型吗? 如果是,请尝试以下方法:

1)尝试播放其他格式的视频,例如.avi,.mkv等。

2)尝试在URI的开头添加file:///

@"file:///C:\Users\Hanif\Documents\Visual Studio 2010\Projects\Education Visualization\Vlc\Resources\Video1.wmv"

3) 尝试在add命令中添加两个参数:

axVLC.playlist.add(@"C:\Users\Hanif\Documents\Visual Studio 2010\Projects\Education Visualization\Vlc\Resources\Video1.wmv", null, null);

我已经寻找这个解决方案很久了!你的答案是唯一有效的!我无法表达对你帮助的感激之情!上帝保佑你! - PiggyChu001

1

只有在路径前加上“file:///”,才能播放本地文件,否则无法播放。在经过长时间的尝试后发现这一点。以下是代码:

string f = @"file:///D:\abc.mp4";
string f2 = @"file:///D:\def.avi";
int i = VLCPlayer.playlist.add(f);
int j = VLCPlayer.playlist.add(f2);

VLCPlayer.playlist.playItem(j);  // to play def.avi
//VLCPlayer.playlist.play();  // to play abc.mp4

0

试试这个:

private void btnPlay_Click(object sender, EventArgs e)
{
    axVLC.playlist.playNext();
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接