aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/Browser.cpp
diff options
context:
space:
mode:
authorq5sys <jt@ixsystems.com>2017-10-03 15:26:14 -0400
committerq5sys <jt@ixsystems.com>2017-10-03 15:26:14 -0400
commit31bcc76104f1b2bb6b392835d216e56dadc3a9c4 (patch)
treed994a0885195a8cf139c6304e8aceb5dcdd6a611 /src-qt5/desktop-utils/lumina-fm/Browser.cpp
parentRevert "rework video thumbnail code" (diff)
parentAdded experimental video thumbnails in lumina-fm and fileinfo (diff)
downloadlumina-31bcc76104f1b2bb6b392835d216e56dadc3a9c4.tar.gz
lumina-31bcc76104f1b2bb6b392835d216e56dadc3a9c4.tar.bz2
lumina-31bcc76104f1b2bb6b392835d216e56dadc3a9c4.zip
Merge branch 'master' of http://github.com/trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/Browser.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp62
1 files changed, 51 insertions, 11 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index f2bdc178..e57b6aed 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -16,10 +16,13 @@
Browser::Browser(QObject *parent) : QObject(parent){
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(fileChanged(QString)) );
- connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
+ connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(dirChanged(QString)) );
showHidden = false;
showThumbs = false;
imageFormats = LUtils::imageExtensions(false); //lowercase suffixes
+ videoFormats = LUtils::videoExtensions(); //lowercase suffixes
+ //connect(surface, SIGNAL(frameReceived(QImage)), this, SLOT(captureFrame(QImage)));
+ //connect(player, &QMediaPlayer::mediaStatusChanged, this, [&]{ stopVideo(player, player->mediaStatus()); });
connect(this, SIGNAL(threadDone(QString, QImage)), this, SLOT(futureFinished(QString, QImage))); //will always be between different threads
}
@@ -60,12 +63,11 @@ void Browser::loadItem(QString info, Browser *obj){
file.close();
pix.loadFromData(bytes);
if(pix.width() > 256 || pix.height() > 256 ){
- pix = pix.scaled(256,256, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ pix = pix.scaled(256,256, Qt::KeepAspectRatio);
}
}
}
-
- //qDebug() << " - done with item:" << info;
+ qDebug() << " - done with item:" << info;
obj->emit threadDone(info, pix);
}
@@ -92,22 +94,60 @@ 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;
+ if(status == QMediaPlayer::BufferedMedia) {
+ qDebug() << "stoppingVideo" << player << player->currentMedia().canonicalUrl();
+ player->setPosition(player->duration() / 2);
+ player->pause();
+ }
+}
+
+void Browser::captureFrame(QImage 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
QIcon ico;
- //LFileInfo info(name);
LFileInfo *info = new LFileInfo(name);
if(!icon.isNull() && showThumbs){
- //qDebug() << " -- Data:";
QPixmap pix = QPixmap::fromImage(icon);
ico.addPixmap(pix);
- //}else if(info->isDir()){
- //qDebug() << " -- Folder:";
- //ico = loadIcon("folder");
}
if(ico.isNull()){
- //qDebug() << " -- MimeType:" << info.fileName() << info.mimetype();
- ico = loadIcon(info->iconfile());
+ if(videoFormats.contains(name.section(".",-1).toLower())) {
+ qDebug() << "Loading Video for" << name;
+ qDebug() << "VIDEO" << info;
+ //qDebug() << obj << this << QThread::currentThread();
+ 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()); });
+ player->setVideoOutput(surface);
+ player->setVolume(0);
+ 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()));
+ delete player;
+ delete surface;
+ }else {
+ ico = loadIcon(info->iconfile());
+ }
}
this->emit itemDataAvailable( ico, info);
//qDebug() << " -- done:" << name;
bgstack15