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

Fix return key, add get_elapsed and get_duration

parent a17c6094
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!186Add the Qt window module as an alternative to the SDL2 module
......@@ -170,13 +170,11 @@ MpvWidget::handle_mpv_event(mpv_event *event)
prop = static_cast<mpv_event_property *>(event->data);
if (strcmp(prop->name, "time-pos") == 0) {
if (prop->format == MPV_FORMAT_DOUBLE) {
double time = *static_cast<double *>(prop->data);
Q_EMIT positionChanged(static_cast<int>(time));
m_position = static_cast<int>(*reinterpret_cast<double*>(prop->data));
}
} else if (strcmp(prop->name, "duration") == 0) {
if (prop->format == MPV_FORMAT_DOUBLE) {
double time = *static_cast<double *>(prop->data);
Q_EMIT durationChanged(static_cast<int>(time));
m_duration = static_cast<int>(*reinterpret_cast<double*>(prop->data));
}
}
break;
......@@ -241,14 +239,14 @@ MpvWidget::on_update(void *ctx)
bool
MpvWidget::get_elapsed(int UNUSED *elapsed_sec)
{
*elapsed_sec = 5;
*elapsed_sec = m_position;
return true;
}
bool
MpvWidget::get_duration(int UNUSED *dur_sec)
{
*dur_sec = 90;
*dur_sec = m_duration;
return true;
}
......@@ -345,10 +343,12 @@ MpvWidget::keyPressEvent(QKeyEvent* event)
lmpv_toggle_pause(mpv);
//lkt_queue_send(m_queue, LKT_EVENT_PLAY_TOGGLE, LKT_PLAY_TOGGLE);
break;
case Qt::Key_Enter:
case Qt::Key_Return:
LOG_DEBUG("WINDOW", "RETURN PRESSED");
lkt_queue_send(m_queue, LKT_EVENT_PLAY_NEXT, nullptr);
break;
case Qt::Key_Less:
LOG_DEBUG("WINDOW", "LESS PRESSED");
lkt_queue_send(m_queue, LKT_EVENT_PLAY_PREV, nullptr);
break;
case Qt::Key_Left:
......
......@@ -15,9 +15,6 @@ public:
void setProperty(const QString &name, const QVariant &value);
QVariant getProperty(const QString &name) const;
QSize sizeHint() const { return QSize(480, 270); }
Q_SIGNALS:
void durationChanged(int value);
void positionChanged(int value);
protected:
void initializeGL() Q_DECL_OVERRIDE;
......@@ -38,6 +35,9 @@ private:
lkt_db *m_db;
struct module_reg *m_reg;
int m_position;
int m_duration;
protected:
void keyPressEvent(QKeyEvent* event);
......
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