diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2017-10-03 18:44:22 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2017-10-03 18:44:22 -0400 |
commit | 2a9d6daa5afa326cc9769d23a64345efeb891ea7 (patch) | |
tree | 4c127b4e4422d427d2ee8511d64acc060dc3c080 | |
parent | Reworked the VideoSurface subclass (diff) | |
download | lumina-2a9d6daa5afa326cc9769d23a64345efeb891ea7.tar.gz lumina-2a9d6daa5afa326cc9769d23a64345efeb891ea7.tar.bz2 lumina-2a9d6daa5afa326cc9769d23a64345efeb891ea7.zip |
Reworked the video thumnail system with lumina-fm
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 29 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 9 |
2 files changed, 14 insertions, 24 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index e57b6aed..bebb92e7 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -94,8 +94,8 @@ void Browser::dirChanged(QString dir){ else if(dir.startsWith(currentDir)){ QtConcurrent::run(this, &Browser::loadItem, dir, this ); } } -/*void Browser::stopVideo(QMediaPlayer *player, QMediaPlayer::MediaStatus status) { - qDebug() << status; +void Browser::stopVideo(QMediaPlayer *player, QMediaPlayer::MediaStatus status) { + //qDebug() << status; if(status == QMediaPlayer::BufferedMedia) { qDebug() << "stoppingVideo" << player << player->currentMedia().canonicalUrl(); player->setPosition(player->duration() / 2); @@ -103,11 +103,11 @@ void Browser::dirChanged(QString dir){ } } -void Browser::captureFrame(QImage pix) { +void Browser::captureFrame(QPixmap pix) { qDebug() << "grabbing frame"; videoFrame = pix.scaledToHeight(64); emit frameChanged(); -}*/ +} void Browser::futureFinished(QString name, QImage icon){ //Note: this will be called once for every item that loads @@ -120,29 +120,20 @@ void Browser::futureFinished(QString name, QImage icon){ if(ico.isNull()){ if(videoFormats.contains(name.section(".",-1).toLower())) { qDebug() << "Loading Video for" << name; - qDebug() << "VIDEO" << info; - //qDebug() << obj << this << QThread::currentThread(); + //qDebug() << "VIDEO" << info; QMediaPlayer *player = new QMediaPlayer(0, QMediaPlayer::VideoSurface); qDebug() << " - created player"; LVideoSurface *surface = new LVideoSurface(); qDebug() << " - Create objects"; - //connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(captureFrame(QImage))); - //connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); }); + connect(surface, SIGNAL(frameReceived(QPixmap)), this, SLOT(captureFrame(QPixmap))); + connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); }); player->setVideoOutput(surface); - player->setVolume(0); + player->setMuted(true); player->setMedia(QUrl("file://"+info->absoluteFilePath())); player->play(); - qDebug() << "Wait for buffer"; - while(player->mediaStatus()!=QMediaPlayer::BufferedMedia){ - QCoreApplication::processEvents(); - } player->pause(); - player->setPosition(player->duration()/2); - while(!surface->frameReady()) { - QCoreApplication::processEvents(); - } - qDebug() << "Load Frame"; - ico.addPixmap(QPixmap::fromImage(surface->currentFrame())); + //ico.addPixmap(videoFrame); + ico = loadIcon(info->iconfile()); delete player; delete surface; }else { diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 7ccb5199..2dfae0be 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -45,7 +45,7 @@ public: private: QString currentDir; QFileSystemWatcher *watcher; - //QImage videoFrame; + QPixmap videoFrame; bool showHidden, showThumbs; QStringList imageFormats, videoFormats, oldFiles; QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons @@ -56,13 +56,12 @@ private: private slots: void fileChanged(QString); //tied into the watcher - for file change notifications void dirChanged(QString); // tied into the watcher - for new/removed files in the current dir - //void captureFrame(QImage); - //void stopVideo(QMediaPlayer*, QMediaPlayer::MediaStatus); + void captureFrame(QPixmap); + void stopVideo(QMediaPlayer*, QMediaPlayer::MediaStatus); void futureFinished(QString, QImage); public slots: void loadDirectory(QString dir = ""); - signals: //Main Signals void itemRemoved(QString item); //emitted if a file was removed from the underlying @@ -75,7 +74,7 @@ signals: //Internal signal for the alternate threads void threadDone(QString, QImage); - //void frameChanged(); + void frameChanged(); }; #endif |