1.错开启动
组态中,不要指定流媒体,而是在onload中延迟指定,可避免打开页面时卡顿
void Frm13::onLoad() {
{
AsynWorker *worker = new AsynWorker(getRuntime()->getAppInstance(this_thread::get_id()));
//如需传入局部变量,可在网上搜索lambda表达式的用法
worker->invoke([this]() {
std::this_thread::sleep_for(std::chrono::milliseconds(200));//延时200ms
})->onFinished([this]() {
wMVideo1->setMainArg(99, 0, 462, 300, "rtsp://admin:whxtt2022@192.168.1.64:554/Streaming/Channels/103");
wMVideo1->play(1000);
wMVideo2->setMainArg(560, 0, 466, 300, "rtsp://192.168.1.244:554/user=admin&password=&channel=1&stream=1.sdp?");
wMVideo2->play(3000);
wMVideo3->setMainArg(308, 299, 466, 300, "rtsp://192.168.1.243:554/user=admin&password=&channel=1&stream=1.sdp?");
wMVideo3->play(5000);
})->start();
}
}
2.关闭页面时,先停止播放,防止关闭时的严重卡顿
bool Frm13::onClosing() {
wMVideo1->stop();
wMVideo2->stop();
wMVideo3->stop();
return true;
}
3.一些非主流品牌可能会在播放过程中视频流会卡住,可在定时器中调用一下play (第一个视频控件一般不会卡住)
void Frm13::wMTimer1_timer_cb(uint16_t code, LvEvent e) {
wMVideo2->play();
wMVideo3->play();
}