diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index 24e95974a2715301764beb45f3700ff1f5cf6034..703466fe4c3f60b1dafdcc684747cd60a524607a 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -104,7 +104,7 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept case MPV_EVENT_LOG_MESSAGE: msg = reinterpret_cast<mpv_event_log_message *>(event->data); - qDebug() << "MPV message: [" << msg->prefix << "]" << msg->level << ":" << msg->text; + qDebug("MPV - MSG [%s] %s: %s", msg->prefix, msg->level, msg->text); break; case MPV_EVENT_PROPERTY_CHANGE: @@ -142,11 +142,26 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept qDebug() << "MPV: Reached end of file!"; break; + case MPV_EVENT_COMMAND_REPLY: + qDebug() << "Got return of" << event->reply_userdata; + switch (static_cast<AsyncCmdType>(event->reply_userdata)) { + case AsyncCmdType::None: + break; + + case AsyncCmdType::LoadFile: + qDebug() << "MPV - CMD: File loaded by mpv"; + break; + + case AsyncCmdType::TogglePlayback: + qDebug() << "MPV - CMD: Playback was toggled"; + break; + } + break; + // Explicitly ignored case MPV_EVENT_NONE: case MPV_EVENT_GET_PROPERTY_REPLY: case MPV_EVENT_SET_PROPERTY_REPLY: - case MPV_EVENT_COMMAND_REPLY: case MPV_EVENT_FILE_LOADED: case MPV_EVENT_TRACKS_CHANGED: case MPV_EVENT_TRACK_SWITCHED: @@ -184,7 +199,7 @@ MpvContainer::loadFile(const QString &filename) noexcept const QByteArray c_filename = filename.toUtf8(); const char *args[] = { "loadfile", c_filename.data(), nullptr }; - printMpvError(mpv_command_async(mpv, 0, args)); + printMpvError(mpv_command_async(mpv, AsyncCmdType::LoadFile, args)); } void @@ -214,5 +229,5 @@ void MpvContainer::mpvTogglePlayback() noexcept { const char *cmd[] = { "cycle", "pause", "up", nullptr }; - printMpvError(mpv_command_async(mpv, 0, cmd)); + printMpvError(mpv_command_async(mpv, AsyncCmdType::TogglePlayback, cmd)); } diff --git a/src/UI/DocumentViews/MpvContainer.hh b/src/UI/DocumentViews/MpvContainer.hh index e8ac2cac4fe1207fa6535d337b7117a9d9c5eb07..7170634b3f211226c823cfae092e7eba35c08c89 100644 --- a/src/UI/DocumentViews/MpvContainer.hh +++ b/src/UI/DocumentViews/MpvContainer.hh @@ -19,6 +19,12 @@ class MpvContainer final : public QWidget { Q_OBJECT VIVY_UNMOVABLE_OBJECT(MpvContainer) + enum AsyncCmdType : uint64_t { + None, + LoadFile, + TogglePlayback, + }; + private: bool isPlaybackPaused{ true }; mpv_handle *mpv{ nullptr };