Better handling of forwards / backwards play: fine tune speeds, restore audio...

Better handling of forwards / backwards play: fine tune speeds, restore audio scrubbing on some speeds, display playback speed in monitor toolbar
parent 31a4f3c4
Pipeline #15043 passed with stage
in 20 minutes and 39 seconds
......@@ -1613,8 +1613,12 @@ void GLWidget::switchPlay(bool play, double speed)
m_producer->seek(0);
}
m_producer->set_speed(speed);
if (speed <= 1. || speed > 6.) {
m_consumer->set("scrub_audio", 0);
} else {
m_consumer->set("scrub_audio", 1);
}
m_consumer->start();
m_consumer->set("scrub_audio", 0);
m_consumer->set("refresh", 1);
} else {
emit paused();
......
......@@ -232,6 +232,12 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
QColor bg = scheme.background(KColorScheme::LinkBackground).color();
m_scalingLabel->setStyleSheet(QString("padding-left: %4; padding-right: %4;background-color: rgb(%1,%2,%3);").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(m_scalingLabel->sizeHint().height()/4));
m_toolbar->addWidget(m_scalingLabel);
m_speedLabel = new QLabel(this);
m_speedLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
bg = scheme.background(KColorScheme::PositiveBackground).color();
m_speedLabel->setStyleSheet(QString("padding-left: %4; padding-right: %4;background-color: rgb(%1,%2,%3);").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(m_speedLabel->sizeHint().height()/4));
m_toolbar->addWidget(m_speedLabel);
m_speedLabel->setFixedWidth(0);
QWidget *sp1 = new QWidget(this);
sp1->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_toolbar->addWidget(sp1);
......@@ -1182,8 +1188,15 @@ void Monitor::slotRewind(double speed)
if (currentspeed > -1) {
m_glMonitor->purgeCache();
speed = -1;
resetSpeedInfo();
} else {
speed = currentspeed * 1.5;
m_speedIndex++;
if (m_speedIndex > 4) {
m_speedIndex = 0;
}
speed = -MonitorManager::speedArray[m_speedIndex];
m_speedLabel->setFixedWidth(QWIDGETSIZE_MAX);
m_speedLabel->setText(QString("x%1").arg(speed));
}
}
m_playAction->setActive(true);
......@@ -1198,8 +1211,15 @@ void Monitor::slotForward(double speed)
if (currentspeed < 1) {
m_glMonitor->purgeCache();
speed = 1;
resetSpeedInfo();
} else {
speed = currentspeed * 1.2;
m_speedIndex++;
if (m_speedIndex > 4) {
m_speedIndex = 0;
}
speed = MonitorManager::speedArray[m_speedIndex];
m_speedLabel->setFixedWidth(QWIDGETSIZE_MAX);
m_speedLabel->setText(QString("x%1").arg(speed));
}
}
m_playAction->setActive(true);
......@@ -1299,18 +1319,21 @@ void Monitor::pause()
slotActivateMonitor();
m_glMonitor->switchPlay(false);
m_playAction->setActive(false);
resetSpeedInfo();
}
void Monitor::switchPlay(bool play)
{
m_playAction->setActive(play);
m_glMonitor->switchPlay(play);
resetSpeedInfo();
}
void Monitor::slotSwitchPlay()
{
slotActivateMonitor();
m_glMonitor->switchPlay(m_playAction->isActive());
resetSpeedInfo();
}
void Monitor::slotPlay()
......@@ -2114,12 +2137,14 @@ void Monitor::slotStart()
slotActivateMonitor();
m_glMonitor->switchPlay(false);
m_glMonitor->getControllerProxy()->setPosition(0);
resetSpeedInfo();
}
void Monitor::slotEnd()
{
slotActivateMonitor();
m_glMonitor->switchPlay(false);
resetSpeedInfo();
if (m_id == Kdenlive::ClipMonitor) {
m_glMonitor->getControllerProxy()->setPosition(m_glMonitor->duration() - 1);
} else {
......@@ -2127,6 +2152,13 @@ void Monitor::slotEnd()
}
}
void Monitor::resetSpeedInfo()
{
m_speedIndex = -1;
m_speedLabel->setFixedWidth(0);
m_speedLabel->clear();
}
void Monitor::addSnapPoint(int pos)
{
m_snaps->addPoint(pos);
......
......@@ -224,6 +224,8 @@ private:
QElapsedTimer m_droppedTimer;
double m_displayedFps;
QLabel *m_scalingLabel;
QLabel *m_speedLabel;
int m_speedIndex;
void adjustScrollBars(float horizontal, float vertical);
void loadQmlScene(MonitorSceneType type);
......@@ -232,6 +234,8 @@ private:
void checkDrops(int dropped);
/** @brief Create temporary Mlt::Tractor holding a clip and it's effectless clone */
void buildSplitEffect(Mlt::Producer *original);
/** @brief Reset and hide speed info label */
void resetSpeedInfo();
private slots:
void slotSetThumbFrame();
......
......@@ -31,6 +31,8 @@
#include "kdenlive_debug.h"
#include <QObject>
const double MonitorManager::speedArray[5] = {1.1, 1.5, 3., 5.5, 10.};
MonitorManager::MonitorManager(QObject *parent)
: QObject(parent)
......
......@@ -71,6 +71,7 @@ public:
/** @brief Returns true if the project monitor is visible (and not tabbed under another dock. */
bool projectMonitorVisible() const;
QTimer refreshTimer;
static const double speedArray[5];
public slots:
......
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