临沂罗庄做网站,大兴营销型网站建设,关于中秋节网页设计实训报告,中国建设银官方网站这个问题一直想解决#xff0c;昨天认真研究了一下。
要点
视频用的Widget不能重复使用#xff0c;每次出错后#xff0c;都要新建。
回调函数的处理。
代码1
关键在于libvlc_event_attach
void VideoWidget::play()
{libvlc_media_t* media;if (strstr(video_path, 昨天认真研究了一下。
要点
视频用的Widget不能重复使用每次出错后都要新建。
回调函数的处理。
代码1
关键在于libvlc_event_attach
void VideoWidget::play()
{libvlc_media_t* media;if (strstr(video_path, rtsp)){media libvlc_media_new_location(m_instence, video_path);libvlc_media_add_option(media, :network-caching50);}else{media libvlc_media_new_path(m_instence, video_path);}m_vlcplayer libvlc_media_player_new_from_media(media);libvlc_media_release(media);//关键libvlc_event_manager_t *event_manager libvlc_media_player_event_manager(m_vlcplayer);libvlc_event_attach(event_manager, libvlc_MediaPlayerStopped, (libvlc_callback_t)m_callback, this);//设置窗口句柄libvlc_media_player_set_hwnd(m_vlcplayer,(void*)this-winId());//播放libvlc_media_player_play(m_vlcplayer);
}代码2
上面的m_callback是外部传递进去的代码如下 static void on_vlc_event(const libvlc_event_t *ev, void *param)
{switch (ev-type){case libvlc_MediaPlayerStopped:qDebug() VLC媒体播放器时间 libvlc_MediaPlayerStopped!!!;//g_pVideoManagerWidget-restartVideo((VideoWidget*)param);QMetaObject::invokeMethod(g_pVideoManagerWidget, restartVideo, Qt::QueuedConnection, (VideoWidget*)param);break;default:break;}
}//public slots:
void VideoManagerWidget::restartVideo(VideoWidget* video)
{qDebug() restartVideo video-getVideoPath();char path[128] {0};strcpy(path, video-getVideoPath());RemoveVideo(video);AddVideo(path);this-resizeEvent(nullptr);this-update();
}