aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-12-06 17:14:52 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-12-06 17:14:52 +0100
commite5976e6366a1dfc0f983b2864c1b4c52a946b4f2 (patch)
tree4070c7c45d93823c9e1ffcc732476ac51c8a50b9
parentdebcd1ab00c69fee7add0e443a37f8a1d7d7f170 (diff)
Fix play & loop zone, fix cannot pause near end of clip
-rw-r--r--src/monitor/monitor.cpp23
-rw-r--r--src/monitor/monitor.h1
-rw-r--r--src/renderer.cpp24
-rw-r--r--src/renderer.h3
4 files changed, 35 insertions, 16 deletions
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 18171bc..8a2fe7a 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -195,7 +195,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_playAction->setToolTip( strippedTooltip + " (" + originalPlayAction->shortcut().toString() + ")");
}
m_playMenu->addAction(m_playAction);
- connect(m_playAction, &QAction::triggered, this, &Monitor::slotPlay);
+ connect(m_playAction, &QAction::triggered, this, &Monitor::slotSwitchPlay);
playButton->setMenu(m_playMenu);
playButton->setPopupMode(QToolButton::MenuButtonPopup);
@@ -1087,18 +1087,19 @@ void Monitor::switchPlay(bool play)
render->switchPlay(play);
}
+void Monitor::slotSwitchPlay(bool triggered)
+{
+ if (render == NULL) return;
+ slotActivateMonitor();
+ render->switchPlay(m_playAction->isActive());
+}
+
void Monitor::slotPlay()
{
if (render == NULL) return;
slotActivateMonitor();
- if (render->isPlaying()) {
- m_playAction->setActive(false);
- render->switchPlay(false);
- }
- else {
- m_playAction->setActive(true);
- render->switchPlay(true);
- }
+ m_playAction->setActive(!m_playAction->isActive());
+ render->switchPlay(m_playAction->isActive());
m_ruler->refreshRuler();
}
@@ -1449,7 +1450,9 @@ void Monitor::onFrameDisplayed(const SharedFrame& frame)
{
int position = frame.get_position();
seekCursor(position);
- render->checkFrameNumber(position);
+ if (!render->checkFrameNumber(position)) {
+ m_playAction->setActive(false);
+ }
if (m_rootItem && m_rootItem->objectName() == "root") {
// we are in main view, show frame
m_rootItem->setProperty("framenum", QString::number(position));
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index b3d8d8f..c0f3c49 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -215,6 +215,7 @@ private slots:
void warningMessage(const QString &text);
void slotLockMonitor(bool lock);
void slotAddEffect(QDomElement effect);
+ void slotSwitchPlay(bool triggered);
public slots:
void slotOpenDvdFile(const QString &);
diff --git a/src/renderer.cpp b/src/renderer.cpp
index 9da9601..50bea31 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -1588,8 +1588,10 @@ bool Render::playZone(const GenTime & startTime, const GenTime & stopTime)
requestedSeekPosition = SEEK_INACTIVE;
if (!m_mltProducer || !m_mltConsumer || !m_isActive)
return false;
- m_mltProducer->set("out", (int)(stopTime.frames(m_fps)));
m_mltProducer->seek((int)(startTime.frames(m_fps)));
+ m_mltProducer->set_speed(0);
+ m_mltConsumer->purge();
+ m_mltProducer->set("out", (int)(stopTime.frames(m_fps)));
m_mltProducer->set_speed(1.0);
if (m_mltConsumer->is_stopped()) m_mltConsumer->start();
m_isRefreshing = true;
@@ -1611,8 +1613,7 @@ void Render::seekToFrame(int pos)
if (!m_mltProducer || !m_isActive)
return;
pos = qMax(0, pos - m_mltProducer->get_in());
- pos = qMin(m_mltProducer->get_playtime(), pos);
- resetZoneMode();
+ pos = qMin(m_mltProducer->get_length(), pos);
seek(pos);
}
@@ -1735,13 +1736,13 @@ int Render::getCurrentSeekPosition() const
return (int) m_mltProducer->position();
}
-void Render::checkFrameNumber(int pos)
+bool Render::checkFrameNumber(int pos)
{
if (pos == requestedSeekPosition) {
requestedSeekPosition = SEEK_INACTIVE;
}
if (requestedSeekPosition != SEEK_INACTIVE) {
- double speed = m_mltProducer->get_speed();
+ double speed = m_mltProducer->get_speed();
m_mltProducer->set_speed(0);
m_mltProducer->seek(requestedSeekPosition);
if (speed == 0) {
@@ -1750,7 +1751,20 @@ void Render::checkFrameNumber(int pos)
else m_mltProducer->set_speed(speed);
} else {
m_isRefreshing = false;
+ if (m_isZoneMode) {
+ if (pos >= m_mltProducer->get_int("out") - 1) {
+ if (m_isLoopMode) {
+ m_mltConsumer->purge();
+ m_mltProducer->seek((int)(m_loopStart.frames(m_fps)));
+ m_mltProducer->set_speed(1.0);
+ m_mltConsumer->set("refresh", 1);
+ } else {
+ if (m_mltProducer->get_speed() == 0) return false;
+ }
+ }
+ }
}
+ return true;
}
void Render::emitFrameUpdated(QImage img)
diff --git a/src/renderer.h b/src/renderer.h
index 5debf8f..02cdedd 100644
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -357,6 +357,7 @@ private:
/** @brief Build the MLT Consumer object with initial settings.
* @param profileName The MLT profile to use for the consumer */
//void buildConsumer();
+ /** @brief Restore normal mode */
void resetZoneMode();
void fillSlowMotionProducers();
/** @brief Make sure we inform MLT if we need a lot of threads for avformat producer */
@@ -464,7 +465,7 @@ public slots:
@param replaceProducer If true, the MLT producer will be recreated */
void getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer = true);
/** @brief Renderer moved to a new frame, check seeking */
- void checkFrameNumber(int pos);
+ bool checkFrameNumber(int pos);
void storeSlowmotionProducer(const QString &url, Mlt::Producer *prod, bool replace = false);
void seek(int time);
};