diff options
author | Ken Moore <ken@ixsystems.com> | 2017-10-06 09:24:12 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-10-06 09:24:12 -0400 |
commit | ae823cbc4543f5849b1629fa6e95253cdf1507be (patch) | |
tree | dbf2ceb99369f2a7ff50501636e59aed949afd1f /src-qt5/desktop-utils/lumina-fm | |
parent | Try to ensure that the transient QApplication for user file checks/updates is... (diff) | |
parent | Finished video thumnails for lumina-fm and lumina-fileinfo (diff) | |
download | lumina-ae823cbc4543f5849b1629fa6e95253cdf1507be.tar.gz lumina-ae823cbc4543f5849b1629fa6e95253cdf1507be.tar.bz2 lumina-ae823cbc4543f5849b1629fa6e95253cdf1507be.zip |
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 97 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 2 |
2 files changed, 59 insertions, 40 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index 211ef8d0..e0e79d04 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -66,6 +66,8 @@ void Browser::loadItem(QString info, Browser *obj){ pix = pix.scaled(256,256, Qt::KeepAspectRatio); } } + }else if(videoFormats.contains(info.section(".",-1).toLower()) ){ + videoList.push_back(info); } qDebug() << " - done with item:" << info; obj->emit threadDone(info, pix); @@ -97,60 +99,77 @@ void Browser::dirChanged(QString dir){ void Browser::stopVideo(QMediaPlayer *player, QMediaPlayer::MediaStatus status) { //qDebug() << status; if(status == QMediaPlayer::BufferedMedia) { - qDebug() << "stoppingVideo" << player << player->currentMedia().canonicalUrl(); + //qDebug() << "stoppingVideo" << player << player->currentMedia().canonicalUrl(); player->setPosition(player->duration() / 2); player->pause(); } } void Browser::captureFrame(QPixmap pix, QIcon *ico) { - qDebug() << "grabbing frame"; - *ico = pix.scaledToHeight(64); - emit frameChanged(); + static int received = 0; + //qDebug() << "grabbing frame" << received+1; + *ico = pix/*.scaledToHeight(64)*/; + if(++received == videoList.size()) { + emit frameChanged(); + received = 0; + } } void Browser::futureFinished(QString name, QImage icon){ //Note: this will be called once for every item that loads - QIcon *ico = new QIcon(); - LFileInfo *info = new LFileInfo(name); - if(!icon.isNull() && showThumbs){ - QPixmap pix = QPixmap::fromImage(icon); - ico->addPixmap(pix); - } - if(ico->isNull()){ - if(videoFormats.contains(name.section(".",-1).toLower())) { - qDebug() << "Loading Video for" << name; - //qDebug() << "VIDEO" << info; - QMediaPlayer *player = new QMediaPlayer(0, QMediaPlayer::VideoSurface); - qDebug() << " - created player"; - LVideoSurface *surface = new LVideoSurface(); - qDebug() << " - Create objects"; - connect(surface, &LVideoSurface::frameReceived, this, [&] (QPixmap pix) { captureFrame(pix, ico); }); - connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); }); - player->setVideoOutput(surface); - player->setMuted(true); - player->setMedia(QUrl("file://"+info->absoluteFilePath())); - player->play(); - player->pause(); - - QEventLoop loop; - connect(this, SIGNAL(frameChanged()), &loop, SLOT(quit())); - loop.exec(); - - ico->addPixmap(videoFrame); - //ico = loadIcon(info->iconfile()); - delete player; - delete surface; - }else { - ico = loadIcon(info->iconfile()); - } + QIcon *ico = new QIcon(); + LFileInfo *info = new LFileInfo(name); + if(!icon.isNull() && showThumbs){ + QPixmap pix = QPixmap::fromImage(icon); + ico->addPixmap(pix); + } + if(ico->isNull()){ + if(videoFormats.contains(name.section(".",-1).toLower())) { + QElapsedTimer loadingTime; + //qDebug() << videoList; + //videoList.add(name); + //qDebug() << "Loading Video for" << name; + //qDebug() << "VIDEO" << info; + QMediaPlayer *player = new QMediaPlayer(0, QMediaPlayer::VideoSurface); + //qDebug() << " - created player" << player; + LVideoSurface *surface = new LVideoSurface(); + //qDebug() << " - Create objects"; + connect(surface, &LVideoSurface::frameReceived, this, [&] (QPixmap pix) { captureFrame(pix, ico); }); + connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); }); + player->setVideoOutput(surface); + player->setMuted(true); + QMediaResource video = QMediaResource(QUrl("file://"+info->absoluteFilePath())); + video.setResolution(QSize(64, 64)); + player->setMedia(video); + //player->setMedia(QUrl("file://"+info->absoluteFilePath())); + player->play(); + player->pause(); + + //qDebug() << "Started loop"; + loadingTime.start(); + QTimer timeout; + timeout.setSingleShot(true); + timeout.setInterval(5000); + QEventLoop loop; + connect(this, SIGNAL(frameChanged()), &loop, SLOT(quit()), Qt::DirectConnection); + connect(&timeout, SIGNAL(timeout()), &loop, SLOT(quit())); + loop.exec(); + //qDebug() << "Exited loop"; + + qDebug() << loadingTime.elapsed(); + delete player; + delete surface; + }else { + ico = loadIcon(info->iconfile()); } - this->emit itemDataAvailable( *ico, info); - //qDebug() << " -- done:" << name; + } + this->emit itemDataAvailable( *ico, info); + //qDebug() << " -- done:" << name; } // PUBLIC SLOTS void Browser::loadDirectory(QString dir){ + videoList.clear(); if(dir.isEmpty()){ dir = currentDir; } //reload current directory if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded //qDebug() << "Load Directory" << dir; diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 379753ab..004bf046 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; - QPixmap videoFrame; + QList<QString> videoList; bool showHidden, showThumbs; QStringList imageFormats, videoFormats, oldFiles; QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons |