Commit 82a87bc5 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved bug when setting clip position (when moving in the preview)

parent 97ac46d5
......@@ -42,7 +42,6 @@ GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : m_clip( clip ), m_width( 0
// Adjust the width
setWidth( clip->getLength() );
qDebug() << "ClipLength in frames:" << clip->getLength();
// Automatically adjust future changes
connect( clip, SIGNAL( lengthUpdated() ), this, SLOT( adjustLength() ) );
}
......
......@@ -125,7 +125,6 @@ void Clip::computeLength()
m_length = 0;
m_lengthSeconds = 0;
}
qDebug() << "Length ==" << m_length << "and in seconds:" << m_lengthSeconds;
}
const QStringList& Clip::getMetaTags() const
......
......@@ -248,9 +248,9 @@ void ClipWorkflow::stop()
qDebug() << "ClipWorkflow has already been stopped";
}
void ClipWorkflow::setPosition( float pos )
void ClipWorkflow::setTime( qint64 time )
{
m_mediaPlayer->setPosition( pos );
m_mediaPlayer->setTime( time );
}
bool ClipWorkflow::isRendering() const
......
......@@ -119,7 +119,7 @@ class ClipWorkflow : public QObject
*/
void stop();
void pause();
void setPosition( float pos );
void setTime( qint64 time );
/**
* This method must be used to change the state of the ClipWorkflow
......
......@@ -136,9 +136,7 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
if ( needRepositioning == true )
{
float pos = ( (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) );
pos = pos * ( cw->getClip()->getEnd() - cw->getClip()->getBegin() ) + cw->getClip()->getBegin();
cw->setPosition( pos );
adjustClipTime( currentFrame, start, cw );
}
QMutexLocker lock( cw->getSleepMutex() );
cw->wake();
......@@ -150,9 +148,7 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->startRender( m_paused );
if ( start != currentFrame ) //Clip was not started as its real begining
{
float pos = ( (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) );
pos = pos * ( cw->getClip()->getEnd() - cw->getClip()->getBegin() ) + cw->getClip()->getBegin();
cw->setPosition( pos );
adjustClipTime( currentFrame, start, cw );
}
if ( m_paused == true )
clipWorkflowRenderCompleted( cw );
......@@ -167,9 +163,7 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
if ( needRepositioning == true )
{
float pos = ( (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) );
pos = pos * ( cw->getClip()->getEnd() - cw->getClip()->getBegin() ) + cw->getClip()->getBegin();
cw->setPosition( pos );
adjustClipTime( currentFrame, start, cw );
}
}
else if ( cw->getState() == ClipWorkflow::EndReached )
......@@ -183,8 +177,7 @@ void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
cw->getStateLock()->unlock();
if ( needRepositioning == true )
{
float pos = ( (float)( currentFrame - start ) / (float)(cw->getClip()->getLength()) );
cw->setPosition( pos );
adjustClipTime( currentFrame, start, cw );
}
clipWorkflowRenderCompleted( cw );
}
......@@ -562,3 +555,10 @@ void TrackWorkflow::clear()
m_clips.clear();
m_length = 0;
}
void TrackWorkflow::adjustClipTime( qint64 currentFrame, qint64 start, ClipWorkflow* cw )
{
qint64 nbMs = ( currentFrame - start ) / cw->getClip()->getParent()->getFps() * 1000;
qint64 startFrame = cw->getClip()->getBegin() + nbMs;
cw->setTime( startFrame );
}
......@@ -80,6 +80,7 @@ class TrackWorkflow : public QObject
void stopClipWorkflow( ClipWorkflow* cw );
bool checkEnd( qint64 currentFrame ) const;
void addClip( ClipWorkflow*, qint64 start );
void adjustClipTime( qint64 currentFrame, qint64 start, ClipWorkflow* cw );
private:
......
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