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