LibVLC中播放、录制

video

1:首先官网下载vlc库

2:将下载的库添加到工程目录

3:添加功能接口

bool QtVLCWidget::playMedia(const char* url, PlayType type)
{
	if (type == PT_Url)
	{
		m_media = libvlc_media_new_location(url);
	}
	else if (type == PT_LocalFile)
	{
		m_media = libvlc_media_new_path(url);
	}

    if (m_media == nullptr) {
        fprintf(stderr, "unable to create media %s", url);
        return false;
    }
    m_mp = libvlc_media_player_new_from_media (m_vlc, m_media);
    if (m_mp == nullptr) {
        fprintf(stderr, "unable to create media player");
        libvlc_media_release(m_media);
        return false;
    }
libvlc_video_set_output_callbacks(m_mp,
		mVLC->isOpenGLES() ? libvlc_video_engine_gles2 : libvlc_video_engine_opengl,
		VLCVideo::setup,
		VLCVideo::cleanup,
		VLCVideo::setReportCallbacks,
		VLCVideo::resizeRenderTextures,
		VLCVideo::swap,
		VLCVideo::make_current,
		VLCVideo::get_proc_address,
		nullptr,
		nullptr,
		mVLC.get());

    libvlc_media_player_play (m_mp);

    return true;
}

参考链接:https://download.youkuaiyun.com/download/weixin_38887743/88717306

//创建初始化播放器资源 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] extern public static IntPtr libvlc_new(int argc, IntPtr argv); //创建播放器实例 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_player_new(IntPtr libvlc_instance); // 释放libvlc实例 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_release(IntPtr libvlc_instance); //获取库版本信息 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern String libvlc_get_version(); // 从视频来源(例如Url)构建一个libvlc_meida RTSP [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_new_location(IntPtr libvlc_instance, IntPtr path); // 从本地文件路径构建一个libvlc_media rtsp串流不适合调用此接口 // [MarshalAs(UnmanagedType.LPStr)] string path [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_new_path(IntPtr libvlc_instance, IntPtr path); /// /// 影片长度 /// /// /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_player_get_length(IntPtr libvlc_media_player); //释放对象 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_release(IntPtr libvlc_media_inst); // 将视频(libvlc_media)绑定到播放器上 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_set_media(IntPtr libvlc_media_player, IntPtr libvlc_media); //创建(libvlc_media)播放窗口 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] publ
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

随风逐流wrx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值