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

WINDOW: use mpv_observe_property for deprecated MPV_EVENTs

parent 9d4271c2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!194WINDOW: use mpv_observe_property for deprecated MPV_EVENTs
......@@ -50,6 +50,9 @@ MpvWidget::MpvWidget(queue *queue, lkt_db *db, module_reg *reg, bool *launched,
mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_FLAG);
mpv_observe_property(mpv, 0, "unpause", MPV_FORMAT_FLAG);
mpv_observe_property(mpv, 0, "idle-active", MPV_FORMAT_FLAG);
mpv_set_wakeup_callback(mpv, wakeup, this);
}
......@@ -130,9 +133,6 @@ MpvWidget::handle_mpv_event(mpv_event *event)
(void)prop;
switch (event->event_id) {
case MPV_EVENT_PAUSE: lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PAUSE); break;
case MPV_EVENT_UNPAUSE: lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PLAY); break;
case MPV_EVENT_SHUTDOWN:
lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_STOP);
*m_launched = false;
......@@ -159,16 +159,51 @@ MpvWidget::handle_mpv_event(mpv_event *event)
if (prop->format == MPV_FORMAT_DOUBLE) {
m_duration = static_cast<int>(*reinterpret_cast<double *>(prop->data));
}
}
break;
}
case MPV_EVENT_IDLE:
} else if (strcmp(prop->name, "pause") == 0) {
LOG_DEBUG("WINDOW", "Detected pause");
if (prop->format == MPV_FORMAT_FLAG) {
if (*static_cast<int*>(prop->data))
goto apply_pause;
else
goto apply_unpause;
}
} else if (strcmp(prop->name, "unpause") == 0) {
LOG_DEBUG("WINDOW", "Detected unpause");
if (prop->format == MPV_FORMAT_FLAG) {
if (*static_cast<int*>(prop->data))
goto apply_unpause;
else
goto apply_pause;
}
} else if (strcmp(prop->name, "idle-active") == 0) {
LOG_DEBUG("WINDOW", "Detected idle");
if (prop->format == MPV_FORMAT_FLAG && *static_cast<int*>(prop->data)) {
LOG_DEBUG("WINDOW", "Applying idle");
lkt_queue_make_available(m_queue, static_cast<LKT_EVENT_TYPE>(LKT_EVENT_PLAY));
lkt_queue_make_available(m_queue, static_cast<LKT_EVENT_TYPE>(LKT_EVENT_PROP));
*m_launched = true;
emit titleChanged("[Lektord] Stopped");
}
}
break;
apply_pause:
LOG_DEBUG("WINDOW", "Applying pause");
lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PAUSE);
break;
apply_unpause:
LOG_DEBUG("WINDOW", "Applying unpause");
lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_PLAY);
break;
// TODO: deprecated events that are now monitored with observe_property but that we didn't use
// Check if we want to observe them or not
//case MPV_EVENT_TRACKS_CHANGED:
//case MPV_EVENT_TRACK_SWITCHED:
//case MPV_EVENT_TICK:
//case MPV_EVENT_METADATA_UPDATE:
//case MPV_EVENT_CHAPTER_CHANGE:
}
case MPV_EVENT_LOG_MESSAGE:
case MPV_EVENT_GET_PROPERTY_REPLY:
......@@ -176,16 +211,11 @@ MpvWidget::handle_mpv_event(mpv_event *event)
case MPV_EVENT_NONE:
case MPV_EVENT_COMMAND_REPLY:
case MPV_EVENT_FILE_LOADED:
case MPV_EVENT_TRACKS_CHANGED:
case MPV_EVENT_TRACK_SWITCHED:
case MPV_EVENT_TICK:
case MPV_EVENT_SCRIPT_INPUT_DISPATCH:
case MPV_EVENT_CLIENT_MESSAGE:
case MPV_EVENT_VIDEO_RECONFIG:
case MPV_EVENT_AUDIO_RECONFIG:
case MPV_EVENT_METADATA_UPDATE:
case MPV_EVENT_SEEK:
case MPV_EVENT_CHAPTER_CHANGE:
case MPV_EVENT_PLAYBACK_RESTART:
case MPV_EVENT_QUEUE_OVERFLOW:
case MPV_EVENT_HOOK: break;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter