VLC-基于LIBVLC播放视频

时间:2021-06-11 15:51:27
安装VLC后在安装目录 找到所需要的:sdk 开发使用 ;


plugins 运行使用,必须与执行文件在一个目录

还有核心的dll libvlc.dll 和 libvlccore.dll

VC 代码如下:

#include "vlc/vlc.h"

#pragma comment(lib, "libvlccore.lib")
#pragma comment(lib, "libvlc.lib")

 libvlc_instance_t* vlc = libvlc_new(0,NULL);
 libvlc_media_player_t* player = libvlc_media_player_new(vlc);
 libvlc_media_player_set_hwnd(player,m_hWnd);//关联播放窗口 windows 其它平台使用对应的api
 //libvlc_media_t* media = libvlc_media_new_path(vlc,"F:\\video\\sample_TongZhou.wmv");//播放本地文件
 libvlc_media_t* media = libvlc_media_new_location(vlc,"rtsp://192.168.100.102:554/onvif/live/2");//播放网络流
  
 libvlc_media_player_set_media(player,media);
 libvlc_media_player_play(player);