Commit f19797ab authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

auto start

parent 9ab22267
......@@ -72,6 +72,7 @@ dtkVisualizationViewVideoPlayerPrivate::dtkVisualizationViewVideoPlayerPrivate(Q
connect(this->controls, &dtkVisualizationWidgetsVideoControls::restart,[=] () {
this->player->setPosition(0);
this->player->play();
this->controls->toggle();
});
}
......@@ -151,8 +152,10 @@ void dtkVisualizationViewVideoPlayer::open(void)
}
fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
if (fileDialog.exec() == QDialog::Accepted) {
d->controls->reset();
d->player->setMedia(fileDialog.selectedUrls().first());
d->controls->setVisible(true);
d->controls->toggle();
}
}
......
......@@ -70,21 +70,7 @@ dtkVisualizationWidgetsVideoControls::dtkVisualizationWidgetsVideoControls(QWidg
d->status_item = new dtkVisualizationWidgetsVideoControlsItem(fa::play, 30, parent);
d->rewind = new dtkVisualizationWidgetsVideoControlsItem(fa::stepbackward, 24, parent);
connect(d->status_item, &dtkVisualizationWidgetsVideoControlsItem::clicked, [=] () {
if (d->state == QMediaPlayer::State::StoppedState || QMediaPlayer::State::PausedState) {
d->state = QMediaPlayer::State::PlayingState;
dtkFontAwesome::instance()->setDefaultOption("color", QColor(Qt::gray));
d->status_item->setIcon(fa::pause);
qDebug() << "emitting play";
emit play();
} else {
d->state = QMediaPlayer::State::PausedState;
dtkFontAwesome::instance()->setDefaultOption("color", QColor(Qt::gray));
d->status_item->setIcon(fa::play);
qDebug() << "emitting pause";
emit pause();
}
});
connect(d->status_item, &dtkVisualizationWidgetsVideoControlsItem::clicked, this, &dtkVisualizationWidgetsVideoControls::toggle);
connect(d->rewind, &dtkVisualizationWidgetsVideoControlsItem::clicked, [=]() {
d->state = QMediaPlayer::State::StoppedState;
d->status_item->setIcon(fa::play);
......@@ -137,6 +123,21 @@ void dtkVisualizationWidgetsVideoControls::setPosition(qlonglong pos)
d->progress_bar->setValue(pos);
}
void dtkVisualizationWidgetsVideoControls::toggle(void)
{
if (d->state == QMediaPlayer::State::StoppedState || d->state == QMediaPlayer::State::PausedState) {
d->state = QMediaPlayer::State::PlayingState;
dtkFontAwesome::instance()->setDefaultOption("color", QColor(Qt::gray));
d->status_item->setIcon(fa::pause);
emit play();
} else {
d->state = QMediaPlayer::State::PausedState;
dtkFontAwesome::instance()->setDefaultOption("color", QColor(Qt::gray));
d->status_item->setIcon(fa::play);
emit pause();
}
}
void dtkVisualizationWidgetsVideoControls::setCurrentFrame(qlonglong count)
{
d->progress_bar->setValue(count);
......
......@@ -19,8 +19,9 @@ public:
public:
QMediaPlayer::State state(void) const;
public:
public slots:
void reset(void);
void toggle(void);
signals:
void pause(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment