Commit 90899622 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved mulptiples bugs/crash with ClipRenderer

parent 2f408c66
......@@ -157,7 +157,7 @@ void MainWindow::m_initializeDockWidgets( void )
tr( "Project Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
Qt::TopDockWidgetArea );
setupLibrary();
m_metaDataManager = MetaDataManager::getInstance();
}
......
......@@ -58,13 +58,16 @@ void MediaListWidget::mousePressEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton)
this->m_dragStartPos = event->pos();
QListWidget::mousePressEvent( event );
ListViewMediaItem* item = static_cast<ListViewMediaItem*>( currentItem() );
if ( item == NULL )
return ;
if ( item->getMedia() != m_lastClicked )
{
m_lastClicked = item->getMedia();
emit selectedMediaChanged( m_lastClicked );
}
QListWidget::mousePressEvent( event );
}
void MediaListWidget::mouseMoveEvent( QMouseEvent* event )
......
......@@ -126,6 +126,11 @@ void PreviewWidget::seekSliderPressed()
void PreviewWidget::seekSliderMoved( int )
{
if ( m_renderer->isRendering() == false )
{
m_ui->seekSlider->setValue( 0 );
return ;
}
if ( m_ui->seekSlider->value() == m_ui->seekSlider->maximum() )
{
m_endReached = true;
......@@ -164,10 +169,6 @@ void PreviewWidget::on_pushButtonPlay_clicked()
{
if ( m_previewStopped == true )
m_previewStopped = false;
// int methodIndex = m_currentPreviewRenderer->metaObject()->indexOfMethod("togglePlayPause(bool)");
// qDebug() << methodIndex;
// QMetaMethod method = m_currentPreviewRenderer->metaObject()->method( methodIndex );
// qDebug() << method.invoke( m_currentPreviewRenderer, Qt::QueuedConnection, Q_ARG(bool, false) );
m_renderer->togglePlayPause();
}
......
......@@ -28,7 +28,9 @@
ClipRenderer::ClipRenderer() :
GenericRenderer(),
m_clipLoaded( false ),
m_vlcMedia( NULL )
m_vlcMedia( NULL ),
m_selectedMedia( NULL ),
m_mediaChanged( false )
{
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ) );
......@@ -43,8 +45,11 @@ ClipRenderer::~ClipRenderer()
void ClipRenderer::setMedia( const Media* media )
{
qDebug() << "selected new media";
m_selectedMedia = media;
if ( m_isRendering == true )
m_mediaChanged = true;
else
m_clipLoaded = false;
}
void ClipRenderer::startPreview()
......@@ -62,6 +67,7 @@ void ClipRenderer::startPreview()
m_clipLoaded = true;
m_isRendering = true;
m_paused = false;
m_mediaChanged = false;
}
void ClipRenderer::setPosition( float newPos )
......@@ -78,13 +84,18 @@ void ClipRenderer::stop()
m_isRendering = false;
m_mediaPlayer->stop();
m_paused = false;
if ( m_mediaChanged == true )
m_clipLoaded = false;
}
}
void ClipRenderer::togglePlayPause( bool forcePause )
{
if ( m_clipLoaded == false)
if ( m_clipLoaded == false )
startPreview();
//If for some reason, nothing was loaded in startPreview(), we just return.
if ( m_clipLoaded == false )
return ;
if ( m_paused == false && m_isRendering == true )
{
......
......@@ -54,6 +54,11 @@ private:
bool m_clipLoaded;
LibVLCpp::Media* m_vlcMedia;
const Media* m_selectedMedia;
/**
* \brief This flags is used to know if a new media has been selected in the
* library. If so, we must relaunch the render if the play button is clicked again.
*/
bool m_mediaChanged;
public slots:
void __positionChanged();
......
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