Commit 9054c492 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactored code for "stopped preview" status.

parent 1d0c8cbc
......@@ -26,7 +26,7 @@
ClipPreviewWidget::ClipPreviewWidget( QWidget* renderWidget ) :
GenericPreviewWidget( renderWidget ),
m_clipLoaded( false ), m_videoStopped( true ), m_vlcMedia( NULL )
m_clipLoaded( false ), m_vlcMedia( NULL )
{
}
......@@ -50,22 +50,22 @@ void ClipPreviewWidget::startPreview( Media* media )
m_mediaPlayer->play();
m_clipLoaded = true;
m_videoStopped = false;
m_isRendering = true;
m_paused = false;
}
void ClipPreviewWidget::setPosition( float newPos )
{
if ( m_clipLoaded == false || m_videoStopped == true )
if ( m_clipLoaded == false || m_isRendering == false )
return ;
m_mediaPlayer->setPosition( newPos );
}
void ClipPreviewWidget::stop()
{
if ( m_clipLoaded == true && m_videoStopped == false )
if ( m_clipLoaded == true && m_isRendering == true )
{
m_videoStopped = true;
m_isRendering = false;
m_mediaPlayer->stop();
m_paused = false;
}
......@@ -75,8 +75,8 @@ void ClipPreviewWidget::togglePlayPause( bool forcePause )
{
if ( m_clipLoaded == false)
return ;
if ( m_videoStopped == true )
m_videoStopped = false;
if ( m_isRendering == false )
m_isRendering = true;
if ( m_paused == false )
{
......@@ -92,7 +92,7 @@ void ClipPreviewWidget::togglePlayPause( bool forcePause )
void ClipPreviewWidget::nextFrame()
{
if ( m_videoStopped == false && m_paused == true )
if ( m_isRendering == true && m_paused == true )
{
qint64 interval = static_cast<qint64>( (1.0f / m_mediaPlayer->getFps()) * 1000.0f );
m_mediaPlayer->setTime( m_mediaPlayer->getTime() + interval );
......@@ -101,7 +101,7 @@ void ClipPreviewWidget::nextFrame()
void ClipPreviewWidget::previousFrame()
{
if ( m_videoStopped == false && m_paused == true )
if ( m_isRendering == false && m_paused == true )
{
qint64 interval = static_cast<qint64>( (1.0f / m_mediaPlayer->getFps()) * 1000.0f );
m_mediaPlayer->setTime( m_mediaPlayer->getTime() - interval );
......@@ -131,6 +131,6 @@ void ClipPreviewWidget::__positionChanged()
void ClipPreviewWidget::__endReached()
{
m_mediaPlayer->stop();
m_videoStopped = true;
m_isRendering = false;
emit endReached();
}
......@@ -49,7 +49,6 @@ public:
private:
bool m_clipLoaded;
bool m_videoStopped;
LibVLCpp::Media* m_vlcMedia;
public slots:
......
......@@ -35,7 +35,9 @@ class GenericPreviewWidget : public QObject
Q_DISABLE_COPY( GenericPreviewWidget );
public:
explicit GenericPreviewWidget( QWidget* renderWidget ) : m_paused( false )
explicit GenericPreviewWidget( QWidget* renderWidget ) :
m_paused( false ),
m_isRendering( false )
{
m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer->setDrawable( renderWidget->winId() );
......@@ -55,6 +57,10 @@ public:
{
return m_paused;
}
bool isRendering() const
{
return m_isRendering;
}
protected:
LibVLCpp::MediaPlayer* m_mediaPlayer;
......@@ -65,6 +71,12 @@ protected:
*/
bool m_paused;
/**
* \brief Will be equal to true if a render has been started, even if it paused.
*/
bool m_isRendering;
public slots:
virtual void __positionChanged() = 0;
virtual void __videoPaused() = 0;
......
......@@ -28,7 +28,6 @@
RenderPreviewWidget::RenderPreviewWidget( MainWorkflow* mainWorkflow, QWidget* renderWidget ) :
GenericPreviewWidget( renderWidget ),
m_mainWorkflow( mainWorkflow ),
m_isRendering( false ),
m_framePlayed( false )
{
m_framePlayedLock = new QReadWriteLock;
......
......@@ -60,7 +60,6 @@ class RenderPreviewWidget : public GenericPreviewWidget
private:
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
bool m_isRendering;
QReadWriteLock* m_framePlayedLock;
bool m_framePlayed;
......
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