libvlc_new始终返回null。我已将libvlc.dll和libvlccore.dll复制到我的解决方案目录的debug文件夹中。
我们也尝试调用libvlc_new(0,null)并将环境变量“VLC_PLUGIN_PATH”设置为plugins目录,结果相同。
任何指针出现错误/或者在.net环境中以程序方式访问libVlc API的最佳方式。
请在C#,VS2010中找到下面的代码片段。
IntPtr instance, player ;
string[] args = new string[] {
"-I", "dummy", "--ignore-config",
@"--plugin-path=D:\plugins",
"--vout-filter=deinterlace", "--deinterlace-mode=blend"
};
instance = LibVlc.libvlc_new(args.length, args);
IntPtr media = LibVlc.libvlc_media_new_location(instance, @"rtsp://username assword@IP_address/path");
player = LibVlc.libvlc_media_player_new_from_media(media);
LibVlc.libvlc_media_player_set_hwnd(player, panel1.Handle);
LibVlc.libvlc_media_player_play(player);
we have done P/Invoke for corresponding library calls as:
[DllImport("D:\\myvlc\\myvlc\\bin\\Debug\\libvlc", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr libvlc_new(int argc, [MarshalAs(UnmanagedType.LPArray,
ArraySubType = UnmanagedType.LPStr)] string[] argv);
[DllImport("D:\\myvlc\\myvlc\\bin\\Debug\\libvlc", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr libvlc_media_new_location(IntPtr p_instance,
[MarshalAs(UnmanagedType.LPStr)] string psz_mrl);
[DllImport("D:\\myvlc\\myvlc\\bin\\Debug\\libvlc", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr libvlc_media_player_new_from_media(IntPtr media);
[DllImport("D:\\myvlc\\myvlc\\bin\\Debug\\libvlc", CallingConvention = CallingConvention.Cdecl)]
public static extern void libvlc_media_player_set_hwnd(IntPtr player, IntPtr drawable);
[DllImport("D:\\myvlc\\myvlc\\bin\\Debug\\libvlc", CallingConvention = CallingConvention.Cdecl)]
public static extern void libvlc_media_player_play(IntPtr player);
答案 0 :(得分:3)
param --plugin-path“被忽略了。
通过复制整个插件目录与2.1.3一起使用。
答案 1 :(得分:0)
找到解决方案,您只需将plugins文件夹复制到visual studio解决方案文件夹的debug目录即可。希望这会为其他人尝试相同的事情节省一些时间。我已经尝试了将近一天。