Commit 429b0d64 authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

Update of the Media class. The thread is better use now.

parent 08d61dd4
......@@ -65,9 +65,8 @@ Media::Media( const QString& mrl ) : m_mrl( mrl ), m_snapshot( NULL )
//And now we play the media
m_vlcMediaPlayer = new LibVLCpp::MediaPlayer( m_vlcMedia );
m_isThreadLaunched = false;
m_isThreadFinished = false;
connect(this, SIGNAL(mediaPlayerReady()), this, SLOT(playSlot()));
m_isMediaInitialized = false;
start();
}
void Media::run()
......@@ -77,16 +76,14 @@ void Media::run()
{
if( m_vlcMediaPlayer->isSeekable() && m_vlcMediaPlayer->getLength() > 0 )
{
emit mediaPlayerReady();
m_isThreadFinished = true;
m_vlcMediaPlayer->stop();
m_isMediaInitialized = true;
m_vlcMediaPlayer->pause();
return ;
}
msleep(100);
}
}
Media::~Media()
{
delete m_image;
......@@ -143,17 +140,21 @@ qint64 Media::getLength()
void Media::play()
{
if (!m_isThreadLaunched && !m_isThreadFinished)
if( m_isMediaInitialized )
{
qDebug() << "play";
playSlot();
}
else
{
m_isThreadLaunched = true;
start();
msleep(100);
play();
}
else if (m_isThreadLaunched && m_isThreadFinished)
m_vlcMediaPlayer->play();
}
void Media::playSlot()
{
qDebug() << "playSlot";
m_vlcMediaPlayer->play();
}
......
......@@ -62,8 +62,7 @@ private:
QImage* m_snapshot;
uchar* m_pixelBuffer;
QImage* m_image;
bool m_isThreadLaunched;
bool m_isThreadFinished;
bool m_isMediaInitialized;
private slots:
void playSlot();
......
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