diff --git a/src/backends/mpv/mpv_proxy.cpp b/src/backends/mpv/mpv_proxy.cpp index e9d64918..cb33aaf0 100644 --- a/src/backends/mpv/mpv_proxy.cpp +++ b/src/backends/mpv/mpv_proxy.cpp @@ -1249,6 +1249,7 @@ void MpvProxy::slotStateChanged() void MpvProxy::refreshDecode() { QList canHwTypes; + if (dynamic_cast(m_pParentWidget)->getplaylist()->size() <= 0) return; //bool bIsCanHwDec = HwdecProbe::get().isFileCanHwdec(_file.url(), canHwTypes); if (DecodeMode::SOFTWARE == m_decodeMode) { //1.设置软解 diff --git a/src/libdmr/player_engine.cpp b/src/libdmr/player_engine.cpp index 120d101f..cb934640 100644 --- a/src/libdmr/player_engine.cpp +++ b/src/libdmr/player_engine.cpp @@ -299,7 +299,7 @@ void PlayerEngine::onSubtitlesDownloaded(const QUrl &url, const QList & } if (!_current) return; - if (playlist().currentInfo().url != url) + if (playlist().count() <= 0 || playlist().currentInfo().url != url) return; bool res = false; @@ -318,7 +318,7 @@ void PlayerEngine::onSubtitlesDownloaded(const QUrl &url, const QList & bool PlayerEngine::loadSubtitle(const QFileInfo &fi) { - if (state() == CoreState::Idle) { + if (state() == CoreState::Idle || playlist().count() <= 0) { return true; } if (!_current) return true; diff --git a/src/widgets/mircastwidget.cpp b/src/widgets/mircastwidget.cpp index a953455f..c9efc7f2 100644 --- a/src/widgets/mircastwidget.cpp +++ b/src/widgets/mircastwidget.cpp @@ -500,11 +500,13 @@ void MircastWidget::startDlnaTp(ItemWidget *item) return; } else { dmr::PlayerEngine *pEngine = static_cast(m_pEngine); - if(pEngine && pEngine->playlist().currentInfo().url.isLocalFile()) { - m_dlnaContentServer->setDlnaFileName(pEngine->playlist().currentInfo().url.toLocalFile()); - m_sLocalUrl = m_dlnaContentServer->getBaseUrl() + QFileInfo(pEngine->playlist().currentInfo().url.toLocalFile()).fileName().toLatin1(); - } else { - m_sLocalUrl = pEngine->playlist().currentInfo().url.toString(); + if(pEngine && pEngine->playlist().count() > 0) { + if(pEngine && pEngine->playlist().currentInfo().url.isLocalFile()) { + m_dlnaContentServer->setDlnaFileName(pEngine->playlist().currentInfo().url.toLocalFile()); + m_sLocalUrl = m_dlnaContentServer->getBaseUrl() + QFileInfo(pEngine->playlist().currentInfo().url.toLocalFile()).fileName().toLatin1(); + } else { + m_sLocalUrl = pEngine->playlist().currentInfo().url.toString(); + } } m_isStartHttpServer = m_dlnaContentServer->getIsStartHttpServer(); } diff --git a/src/widgets/platform/platform_toolbox_proxy.cpp b/src/widgets/platform/platform_toolbox_proxy.cpp index 850493cb..782a282a 100644 --- a/src/widgets/platform/platform_toolbox_proxy.cpp +++ b/src/widgets/platform/platform_toolbox_proxy.cpp @@ -809,7 +809,7 @@ void Platform_viewProgBarLoad::loadViewProgBar(QSize size) int length = strlen(time.toString("hh:mm:ss").toLatin1().data()); memcpy(m_seekTime, time.toString("hh:mm:ss").toLatin1().data(), length + 1); m_video_thumbnailer->seek_time = m_seekTime; - + if(m_pEngine->playlist().count() <= 0 ) return; auto url = m_pEngine->playlist().currentInfo().url; auto file = QFileInfo(url.toLocalFile()).absoluteFilePath(); @@ -894,11 +894,13 @@ void Platform_ToolboxProxy::finishLoadSlot(QSize size) if(CompositingManager::get().platform() == Platform::X86) { if (m_pEngine->state() != PlayerEngine::CoreState::Idle) { - PlayItemInfo info = m_pEngine->playlist().currentInfo(); - if (!info.url.isLocalFile()) { - return; + if(m_pEngine->playlist().count() > 0) { + PlayItemInfo info = m_pEngine->playlist().currentInfo(); + if (!info.url.isLocalFile()) { + return; + } + m_pProgBar_Widget->setCurrentIndex(2); } - m_pProgBar_Widget->setCurrentIndex(2); } } } @@ -1418,7 +1420,7 @@ void Platform_ToolboxProxy::updateHoverPreview(const QUrl &url, int secs) if (m_pEngine->state() == PlayerEngine::CoreState::Idle) return; - if (m_pEngine->playlist().currentInfo().url != url) + if (m_pEngine->playlist().count() <= 0 || m_pEngine->playlist().currentInfo().url != url) return; if (!Settings::get().isSet(Settings::PreviewOnMouseover)) @@ -1569,7 +1571,9 @@ void Platform_ToolboxProxy::slotThemeTypeChanged() } if(m_pEngine->state() != PlayerEngine::CoreState::Idle) { - bRawFormat = m_pEngine->getplaylist()->currentInfo().mi.isRawFormat(); + if(m_pEngine->getplaylist()->count() > 0) { + bRawFormat = m_pEngine->getplaylist()->currentInfo().mi.isRawFormat(); + } if(bRawFormat && !m_pEngine->currFileIsAudio()) { m_pTimeLabel->setPalette(textPalette); m_pTimeLabelend->setPalette(textPalette); @@ -1691,7 +1695,7 @@ void Platform_ToolboxProxy::slotFileLoaded() } } } - if(isAllAudio) { + if(isAllAudio || m_pEngine->getplaylist()->count() <= 0) { m_pMainWindow->slotExitMircast(); return; } @@ -1798,7 +1802,7 @@ void Platform_ToolboxProxy::slotPlayListStateChange(bool isShortcut) void Platform_ToolboxProxy::slotUpdateThumbnailTimeOut() { //如果视频长度小于1s应该直接返回不然会UI错误 - if (m_pEngine->playlist().currentInfo().mi.duration < 1) { + if (m_pEngine->getplaylist()->count() <= 0 || m_pEngine->playlist().currentInfo().mi.duration < 1) { return; } @@ -1947,7 +1951,7 @@ void Platform_ToolboxProxy::progressHoverChanged(int nValue) if (m_pEngine->state() == PlayerEngine::CoreState::Idle) return; - if (m_pVolSlider->isVisible()) + if (m_pVolSlider->isVisible() || m_pEngine->getplaylist()->count() <= 0) return; const auto &pif = m_pEngine->playlist().currentInfo(); @@ -2055,7 +2059,7 @@ void Platform_ToolboxProxy::updateButtonStates() palette.setColor(QPalette::Text, QColor(255, 255, 255, 40)); } - if(m_pEngine->state() != PlayerEngine::CoreState::Idle) { + if(m_pEngine->state() != PlayerEngine::CoreState::Idle && m_pEngine->getplaylist()->count() > 0) { bRawFormat = m_pEngine->getplaylist()->currentInfo().mi.isRawFormat(); m_pMircastBtn->setEnabled(!m_pEngine->currFileIsAudio()); if(m_pEngine->currFileIsAudio()) diff --git a/src/widgets/toolbox_proxy.cpp b/src/widgets/toolbox_proxy.cpp index 449c7522..0076fa28 100644 --- a/src/widgets/toolbox_proxy.cpp +++ b/src/widgets/toolbox_proxy.cpp @@ -995,11 +995,13 @@ void ToolboxProxy::finishLoadSlot(QSize size) if(CompositingManager::get().platform() == Platform::X86) { if (m_pEngine->state() != PlayerEngine::CoreState::Idle) { - PlayItemInfo info = m_pEngine->playlist().currentInfo(); - if (!info.url.isLocalFile()) { - return; + if(m_pEngine->playlist().count() > 0) { + PlayItemInfo info = m_pEngine->playlist().currentInfo(); + if (!info.url.isLocalFile()) { + return; + } + m_pProgBar_Widget->setCurrentIndex(2); } - m_pProgBar_Widget->setCurrentIndex(2); } } } @@ -1544,7 +1546,7 @@ void ToolboxProxy::updateHoverPreview(const QUrl &url, int secs) if (m_pEngine->state() == PlayerEngine::CoreState::Idle) return; - if (m_pEngine->playlist().currentInfo().url != url) + if (m_pEngine->playlist().count() <= 0 || m_pEngine->playlist().currentInfo().url != url) return; if (!Settings::get().isSet(Settings::PreviewOnMouseover)) @@ -1823,6 +1825,7 @@ void ToolboxProxy::slotFileLoaded() m_pMainWindow->slotExitMircast(); return; } + if(m_pEngine->getplaylist()->count() <= 0) return; QString sCurPath = m_pEngine->getplaylist()->currentInfo().mi.filePath; int nIndex = -1; for(int i = 0; i < lstItemInfo.count(); i++) { @@ -2119,7 +2122,7 @@ void ToolboxProxy::progressHoverChanged(int nValue) if (m_pEngine->state() == PlayerEngine::CoreState::Idle) return; - if (m_pVolSlider->isVisible()) + if (m_pEngine->getplaylist()->count() <= 0 || m_pVolSlider->isVisible()) return; const auto &pif = m_pEngine->playlist().currentInfo(); @@ -2228,7 +2231,7 @@ void ToolboxProxy::updateButtonStates() palette.setColor(QPalette::Text, QColor(255, 255, 255, 40)); } - if(m_pEngine->state() != PlayerEngine::CoreState::Idle) { + if(m_pEngine->state() != PlayerEngine::CoreState::Idle && m_pEngine->getplaylist()->count() > 0) { bRawFormat = m_pEngine->getplaylist()->currentInfo().mi.isRawFormat(); m_pMircastBtn->setEnabled(!m_pEngine->currFileIsAudio()); if(m_pEngine->currFileIsAudio())