Commit 20e26777 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved bug when using previewWidget with a clip and not a media.

parent af8ef7a5
......@@ -156,6 +156,7 @@ MediaListViewController::clipSelection( const QUuid& uuid )
{
Clip* clip;
if ( ( clip = Library::getInstance()->clip( m_currentUuid, uuid ) ) != 0 )
{
emit clipSelected( clip );
}
}
......@@ -107,7 +107,7 @@ void ClipRenderer::startPreview()
m_mediaPlayer->setMedia( m_vlcMedia );
m_mediaPlayer->play();
m_mediaPlayer->setPosition( m_begin / m_selectedMedia->getNbFrames() );
m_mediaPlayer->setPosition( (double)m_begin / (double)m_selectedMedia->getNbFrames() );
m_clipLoaded = true;
m_isRendering = true;
m_paused = false;
......@@ -174,6 +174,11 @@ void ClipRenderer::previousFrame()
}
}
qint64 ClipRenderer::getLength() const
{
return m_end - m_begin;
}
qint64 ClipRenderer::getLengthMs() const
{
if ( m_selectedMedia )
......@@ -223,6 +228,7 @@ void ClipRenderer::previewWidgetCursorChanged( qint64 newFrame )
{
if ( m_isRendering == true )
{
newFrame += m_begin;
qint64 nbSeconds = qRound64( (qreal)newFrame / m_selectedMedia->getFps() );
m_mediaPlayer->setTime( nbSeconds * 1000 );
}
......@@ -259,6 +265,12 @@ void ClipRenderer::__timeChanged( qint64 time )
if ( fps < 0.1f )
fps = m_selectedMedia->getFps();
qint64 f = qRound64( (qreal)time / 1000.0 * fps );
if ( f >= m_end )
{
__endReached();
return ;
}
f = f - m_begin;
emit frameChanged( f, MainWorkflow::Renderer );
}
......
......@@ -43,6 +43,7 @@ public:
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
virtual qint64 getLength() const;
virtual qint64 getLengthMs() const;
virtual qint64 getCurrentFrame() const;
virtual float getFps() const;
......@@ -70,7 +71,14 @@ public slots:
virtual void mediaUnloaded( const QUuid& );
virtual void previewWidgetCursorChanged( qint64 newFrame );
// void __positionChanged();
/**
* \brief Triggered at every libvlc_MediaPlayerTimeChanged event.
*
* This slot will compute a frame number based on the time and the clip's FPS.
* Once computed, it will emit a frameChanged signal, with the reason Renderer.
* \warning The frame number computed may be unaccurate.
* \sa frameChanged();
*/
void __timeChanged( qint64 time );
void __endReached();
void __videoStopped();
......
......@@ -98,10 +98,7 @@ public:
* \brief Return the length in frames
* \warning The returned value may not be accurate
*/
qint64 getLength() const
{
return qRound64( (qreal)getLengthMs() / 1000.0 * (qreal)getFps() );
}
virtual qint64 getLength() const = 0;
/**
* \brief Return true if the renderer is paused
......
......@@ -214,6 +214,11 @@ qint64 WorkflowRenderer::getCurrentFrame() const
return m_mainWorkflow->getCurrentFrame();
}
qint64 WorkflowRenderer::getLength() const
{
return qRound64( (qreal)getLengthMs() / 1000.0 * (qreal)getFps() );
}
qint64 WorkflowRenderer::getLengthMs() const
{
return m_mainWorkflow->getLengthFrame() / getFps() * 1000;
......
......@@ -47,6 +47,7 @@ class WorkflowRenderer : public GenericRenderer
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
virtual qint64 getLength() const;
virtual qint64 getLengthMs() const;
virtual qint64 getCurrentFrame() const;
virtual float getFps() const;
......
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