diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index 2f59fcc626b27b6b0e2296a2ad375f0b41b65a50..e9866e6297a2e10d144b4a27fe1a7321cc6e7d8f 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -33,13 +33,13 @@ MpvContainer::MpvContainer(QWidget *parent) mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE); - connect(this, &MpvContainer::mpvEvent, this, &MpvContainer::onMpvEvent, Qt::QueuedConnection); - mpv_set_wakeup_callback(mpv, &MpvContainer::mpvEventWakeUpCB, this); - if (int rc = mpv_initialize(mpv); rc < 0) { printMpvError(rc); throw std::runtime_error("Failed to initialize the mpv context"); } + + connect(this, &MpvContainer::mpvEvent, this, &MpvContainer::onMpvEvent, Qt::QueuedConnection); + mpv_set_wakeup_callback(mpv, &MpvContainer::mpvEventWakeUpCB, this); } void @@ -78,7 +78,6 @@ void MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept { // Declare here variables that can be used in the switch-case statements - qint64 w, h; double time; QString msgText; union { @@ -94,14 +93,6 @@ MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept switch (event->event_id) { case MPV_EVENT_SHUTDOWN: closeMpv(); break; - case MPV_EVENT_VIDEO_RECONFIG: - // TODO: Those are sync calls, prefer async calls - if (mpv_get_property(mpv, "dwidth", MPV_FORMAT_INT64, &w) >= 0 && - mpv_get_property(mpv, "dheight", MPV_FORMAT_INT64, &h) >= 0 && (w > 0 && h > 0)) { - qDebug() << "Reconfigure video to" << w << "x" << h; - } - break; - case MPV_EVENT_LOG_MESSAGE: msg = reinterpret_cast<mpv_event_log_message *>(event->data); msgText = QString::fromUtf8(msg->text); @@ -143,7 +134,6 @@ MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept break; case MPV_EVENT_START_FILE: qDebug() << "MPV: Begin of file"; break; - case MPV_EVENT_END_FILE: qDebug() << "MPV: Reached end of file!"; break; case MPV_EVENT_COMMAND_REPLY: @@ -152,6 +142,7 @@ MpvContainer::handleMpvEvent(const mpv_event *const event) noexcept break; // Explicitly ignored + case MPV_EVENT_VIDEO_RECONFIG: case MPV_EVENT_NONE: case MPV_EVENT_GET_PROPERTY_REPLY: case MPV_EVENT_SET_PROPERTY_REPLY: