Skip to content
Extraits de code Groupes Projets
Vérifiée Valider e39c45e7 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

UI: Can now get the reply code for async commands

parent 60ea493c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!15Video playback with mpv
...@@ -104,7 +104,7 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept ...@@ -104,7 +104,7 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept
case MPV_EVENT_LOG_MESSAGE: case MPV_EVENT_LOG_MESSAGE:
msg = reinterpret_cast<mpv_event_log_message *>(event->data); 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; break;
case MPV_EVENT_PROPERTY_CHANGE: case MPV_EVENT_PROPERTY_CHANGE:
...@@ -142,11 +142,26 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept ...@@ -142,11 +142,26 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept
qDebug() << "MPV: Reached end of file!"; qDebug() << "MPV: Reached end of file!";
break; 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 // Explicitly ignored
case MPV_EVENT_NONE: case MPV_EVENT_NONE:
case MPV_EVENT_GET_PROPERTY_REPLY: case MPV_EVENT_GET_PROPERTY_REPLY:
case MPV_EVENT_SET_PROPERTY_REPLY: case MPV_EVENT_SET_PROPERTY_REPLY:
case MPV_EVENT_COMMAND_REPLY:
case MPV_EVENT_FILE_LOADED: case MPV_EVENT_FILE_LOADED:
case MPV_EVENT_TRACKS_CHANGED: case MPV_EVENT_TRACKS_CHANGED:
case MPV_EVENT_TRACK_SWITCHED: case MPV_EVENT_TRACK_SWITCHED:
...@@ -184,7 +199,7 @@ MpvContainer::loadFile(const QString &filename) noexcept ...@@ -184,7 +199,7 @@ MpvContainer::loadFile(const QString &filename) noexcept
const QByteArray c_filename = filename.toUtf8(); const QByteArray c_filename = filename.toUtf8();
const char *args[] = { "loadfile", c_filename.data(), nullptr }; const char *args[] = { "loadfile", c_filename.data(), nullptr };
printMpvError(mpv_command_async(mpv, 0, args)); printMpvError(mpv_command_async(mpv, AsyncCmdType::LoadFile, args));
} }
void void
...@@ -214,5 +229,5 @@ void ...@@ -214,5 +229,5 @@ void
MpvContainer::mpvTogglePlayback() noexcept MpvContainer::mpvTogglePlayback() noexcept
{ {
const char *cmd[] = { "cycle", "pause", "up", nullptr }; const char *cmd[] = { "cycle", "pause", "up", nullptr };
printMpvError(mpv_command_async(mpv, 0, cmd)); printMpvError(mpv_command_async(mpv, AsyncCmdType::TogglePlayback, cmd));
} }
...@@ -19,6 +19,12 @@ class MpvContainer final : public QWidget { ...@@ -19,6 +19,12 @@ class MpvContainer final : public QWidget {
Q_OBJECT Q_OBJECT
VIVY_UNMOVABLE_OBJECT(MpvContainer) VIVY_UNMOVABLE_OBJECT(MpvContainer)
enum AsyncCmdType : uint64_t {
None,
LoadFile,
TogglePlayback,
};
private: private:
bool isPlaybackPaused{ true }; bool isPlaybackPaused{ true };
mpv_handle *mpv{ nullptr }; mpv_handle *mpv{ nullptr };
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter