Commit 1d0c8cbc authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactored pausing code.

Next/previous frame is only usable when paused.
Added .o, .so, and include/ dir to .gitignore
parent e44dd010
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
/qtc-gdbmacros /qtc-gdbmacros
/ts/*.qm /ts/*.qm
Makefile* Makefile*
/include
*.pro.user *.pro.user
moc_*.cpp moc_*.cpp
ui_*.h ui_*.h
.*.swp .*.swp
*~ *~
*.o
*.so*
qrc_ressources.cpp qrc_ressources.cpp
...@@ -51,6 +51,7 @@ void ClipPreviewWidget::startPreview( Media* media ) ...@@ -51,6 +51,7 @@ void ClipPreviewWidget::startPreview( Media* media )
m_mediaPlayer->play(); m_mediaPlayer->play();
m_clipLoaded = true; m_clipLoaded = true;
m_videoStopped = false; m_videoStopped = false;
m_paused = false;
} }
void ClipPreviewWidget::setPosition( float newPos ) void ClipPreviewWidget::setPosition( float newPos )
...@@ -66,6 +67,7 @@ void ClipPreviewWidget::stop() ...@@ -66,6 +67,7 @@ void ClipPreviewWidget::stop()
{ {
m_videoStopped = true; m_videoStopped = true;
m_mediaPlayer->stop(); m_mediaPlayer->stop();
m_paused = false;
} }
} }
...@@ -76,15 +78,21 @@ void ClipPreviewWidget::togglePlayPause( bool forcePause ) ...@@ -76,15 +78,21 @@ void ClipPreviewWidget::togglePlayPause( bool forcePause )
if ( m_videoStopped == true ) if ( m_videoStopped == true )
m_videoStopped = false; m_videoStopped = false;
if ( m_mediaPlayer->isPlaying() ) if ( m_paused == false )
{
m_mediaPlayer->pause(); m_mediaPlayer->pause();
m_paused = true;
}
else if ( forcePause == false ) else if ( forcePause == false )
{
m_mediaPlayer->play(); m_mediaPlayer->play();
m_paused = false;
}
} }
void ClipPreviewWidget::nextFrame() void ClipPreviewWidget::nextFrame()
{ {
if ( m_videoStopped == false ) if ( m_videoStopped == false && m_paused == true )
{ {
qint64 interval = static_cast<qint64>( (1.0f / m_mediaPlayer->getFps()) * 1000.0f ); qint64 interval = static_cast<qint64>( (1.0f / m_mediaPlayer->getFps()) * 1000.0f );
m_mediaPlayer->setTime( m_mediaPlayer->getTime() + interval ); m_mediaPlayer->setTime( m_mediaPlayer->getTime() + interval );
...@@ -93,7 +101,7 @@ void ClipPreviewWidget::nextFrame() ...@@ -93,7 +101,7 @@ void ClipPreviewWidget::nextFrame()
void ClipPreviewWidget::previousFrame() void ClipPreviewWidget::previousFrame()
{ {
if ( m_videoStopped == false ) if ( m_videoStopped == false && m_paused == true )
{ {
qint64 interval = static_cast<qint64>( (1.0f / m_mediaPlayer->getFps()) * 1000.0f ); qint64 interval = static_cast<qint64>( (1.0f / m_mediaPlayer->getFps()) * 1000.0f );
m_mediaPlayer->setTime( m_mediaPlayer->getTime() - interval ); m_mediaPlayer->setTime( m_mediaPlayer->getTime() - interval );
......
...@@ -35,7 +35,7 @@ class GenericPreviewWidget : public QObject ...@@ -35,7 +35,7 @@ class GenericPreviewWidget : public QObject
Q_DISABLE_COPY( GenericPreviewWidget ); Q_DISABLE_COPY( GenericPreviewWidget );
public: public:
explicit GenericPreviewWidget( QWidget* renderWidget ) explicit GenericPreviewWidget( QWidget* renderWidget ) : m_paused( false )
{ {
m_mediaPlayer = new LibVLCpp::MediaPlayer(); m_mediaPlayer = new LibVLCpp::MediaPlayer();
m_mediaPlayer->setDrawable( renderWidget->winId() ); m_mediaPlayer->setDrawable( renderWidget->winId() );
...@@ -51,9 +51,19 @@ public: ...@@ -51,9 +51,19 @@ public:
virtual void nextFrame() = 0; virtual void nextFrame() = 0;
virtual void previousFrame() = 0; virtual void previousFrame() = 0;
virtual void stop() = 0; virtual void stop() = 0;
bool isPaused() const
{
return m_paused;
}
protected: protected:
LibVLCpp::MediaPlayer* m_mediaPlayer; LibVLCpp::MediaPlayer* m_mediaPlayer;
/**
* \brief This flag allows us to know if the render is paused
* or not, without using libvlc, especially for the render preview.
* If the video is stopped, then this flag will be equal to false
*/
bool m_paused;
public slots: public slots:
virtual void __positionChanged() = 0; virtual void __positionChanged() = 0;
......
...@@ -236,12 +236,12 @@ void PreviewWidget::changedTab( int tabId ) ...@@ -236,12 +236,12 @@ void PreviewWidget::changedTab( int tabId )
void PreviewWidget::on_pushButtonNextFrame_clicked() void PreviewWidget::on_pushButtonNextFrame_clicked()
{ {
if ( m_previewStopped == true ) if ( m_previewStopped == false )
m_currentPreviewRenderer->nextFrame(); m_currentPreviewRenderer->nextFrame();
} }
void PreviewWidget::on_pushButtonPreviousFrame_clicked() void PreviewWidget::on_pushButtonPreviousFrame_clicked()
{ {
if ( m_previewStopped == true ) if ( m_previewStopped == false )
m_currentPreviewRenderer->previousFrame(); m_currentPreviewRenderer->previousFrame();
} }
...@@ -87,6 +87,7 @@ void RenderPreviewWidget::stopPreview() ...@@ -87,6 +87,7 @@ void RenderPreviewWidget::stopPreview()
//This might be called multiple times, but this is due to Qt message loop //This might be called multiple times, but this is due to Qt message loop
m_mediaPlayer->stop(); m_mediaPlayer->stop();
m_isRendering = false; m_isRendering = false;
m_paused = false;
} }
void RenderPreviewWidget::startPreview( Media* ) void RenderPreviewWidget::startPreview( Media* )
...@@ -94,6 +95,7 @@ void RenderPreviewWidget::startPreview( Media* ) ...@@ -94,6 +95,7 @@ void RenderPreviewWidget::startPreview( Media* )
m_mainWorkflow->startRender(); m_mainWorkflow->startRender();
m_mediaPlayer->play(); m_mediaPlayer->play();
m_isRendering = true; m_isRendering = true;
m_paused = false;
} }
void RenderPreviewWidget::setPosition( float newPos ) void RenderPreviewWidget::setPosition( float newPos )
...@@ -131,14 +133,20 @@ void RenderPreviewWidget::togglePlayPause( bool forcePause ) ...@@ -131,14 +133,20 @@ void RenderPreviewWidget::togglePlayPause( bool forcePause )
startPreview( NULL ); startPreview( NULL );
else if ( m_isRendering == true ) else if ( m_isRendering == true )
{ {
if ( m_mediaPlayer->isPlaying() == false && forcePause == false ) if ( m_paused == true && forcePause == false )
{
m_mediaPlayer->play(); m_mediaPlayer->play();
m_paused = false;
}
else else
{ {
//VLC will toggle play if we call pause while already paused... //VLC will toggle play if we call pause while already paused...
//So be careful about pausing two times : //So be careful about pausing two times :
if ( m_mediaPlayer->isPlaying() == true ) if ( m_paused == false )
{
m_mediaPlayer->pause(); m_mediaPlayer->pause();
m_paused = true;
}
} }
} }
} }
......
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