diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-18 12:10:10 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-18 12:10:10 -0400 |
commit | e5f8846fd775269314e5be502261284b9183205e (patch) | |
tree | b87c318f16124b4a56daec9cf77baa78727cecf4 /src-qt5/core/libLumina | |
parent | Another quick checkpoint for Lumina 2 files. Nothing too spectacular yet - st... (diff) | |
download | lumina-e5f8846fd775269314e5be502261284b9183205e.tar.gz lumina-e5f8846fd775269314e5be502261284b9183205e.tar.bz2 lumina-e5f8846fd775269314e5be502261284b9183205e.zip |
Make LVideoLabel thread-safe.
Couple quick fixes for the Browser class in lumina-fm too (minor cleanup).
Diffstat (limited to 'src-qt5/core/libLumina')
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.cpp | 31 | ||||
-rw-r--r-- | src-qt5/core/libLumina/LVideoLabel.h | 11 |
2 files changed, 25 insertions, 17 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp index 3b2ce468..dcc0ad58 100644 --- a/src-qt5/core/libLumina/LVideoLabel.cpp +++ b/src-qt5/core/libLumina/LVideoLabel.cpp @@ -1,16 +1,28 @@ #include "LVideoLabel.h" - +#include <QTimer> LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) { this->setScaledContents(true); - mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); - thumbnail = QPixmap(); - this->setPixmap(thumbnail); + this->setPixmap(thumbnail); //blank pixmap by default entered = false; + filepath = file; + QTimer::singleShot(0, this, SLOT(initializeBackend()) ); +} + +LVideoLabel::~LVideoLabel() { + +} + +void LVideoLabel::setShrinkPixmap(bool shrink) { + this->shrink = shrink; +} + +void LVideoLabel::initializeBackend(){ + mediaPlayer = new QMediaPlayer(this, QMediaPlayer::VideoSurface); surface = new LVideoSurface(this); mediaPlayer->setVideoOutput(surface); mediaPlayer->setPlaybackRate(3); mediaPlayer->setMuted(true); - mediaPlayer->setMedia(QUrl("file://" + file)); + mediaPlayer->setMedia(QUrl::fromLocalFile(filepath)); mediaPlayer->play(); mediaPlayer->pause(); @@ -19,15 +31,6 @@ LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) { this->connect(this, SIGNAL(rollOver()), surface, SLOT(switchRollOver())); } -LVideoLabel::~LVideoLabel() { - mediaPlayer->deleteLater(); - delete surface; -} - -void LVideoLabel::setShrinkPixmap(bool shrink) { - this->shrink = shrink; -} - void LVideoLabel::stopVideo(QPixmap pix) { if(!entered) { emit frameReceived(pix); diff --git a/src-qt5/core/libLumina/LVideoLabel.h b/src-qt5/core/libLumina/LVideoLabel.h index fa590e5a..110e3305 100644 --- a/src-qt5/core/libLumina/LVideoLabel.h +++ b/src-qt5/core/libLumina/LVideoLabel.h @@ -1,5 +1,5 @@ -#ifndef LVIDEOLABEL_H -#define LVIDEOLABEL_H +#ifndef LVIDEOLABEL_H +#define LVIDEOLABEL_H #include <QLabel> #include <QMediaPlayer> @@ -13,21 +13,26 @@ class LVideoLabel : public QLabel { LVideoLabel(QString, QWidget* parent=NULL); ~LVideoLabel(); void setShrinkPixmap(bool); - + protected: void enterEvent(QEvent*); void leaveEvent(QEvent*); + signals: void rollOver(); void frameReceived(QPixmap); + private slots: + void initializeBackend(); void stopVideo(QPixmap); void setDuration(QMediaPlayer::MediaStatus); + private: QMediaPlayer *mediaPlayer; LVideoSurface *surface; QPixmap thumbnail; bool entered; bool shrink; + QString filepath; }; #endif |