使用libvlc开发了一个rtmp的播放器,参考网上的文章《使用libVLC实现的播放器:支持双击全屏》很快实现了。
但是使用的时候发现,如果输入一个错误的RTMP地址,或者流中断,播放器端没有任何提示。
翻看代码:
//************************************
// Method: PlayUrl
// FullName: CVlcPlayer::PlayUrl
// Access: public
// Returns: BOOL
// Qualifier:
// Parameter: CString strUrl
// Mark: 播放网络文件/RTSP/RTMP串流等
//************************************
BOOL CVlcPlayer::PlayUrl( CString strUrl )
{
if (! m_pVLC_Inst)
{
Init();
}
std::string strPath;
strPath = CT2A(strUrl, CP_UTF8);
if(strPath.empty() || ! m_pVLC_Inst)
{
return FALSE;
}
Stop();
BOOL bRet = FALSE;
libvlc_media_t *m;
m = libvlc_media_new_location(m_pVLC_Inst, strPath.c_str());
if (m)
{
if (m_pVLC_Player = libvlc_media_player_new_from_media(m))
{
libvlc_media_player_set_hwnd(m_pVLC_Player, m_hWnd);
libvlc_media_player_play(m_pVLC_Player);
// 事件管理

本文分享了使用libVLC开发RTMP播放器时遇到的问题及解决方案,详细介绍了如何通过添加事件回调处理错误URL和流中断的情况,确保播放器稳定运行。
1962

被折叠的 条评论
为什么被折叠?



