aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm
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
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')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp62
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.h10
-rw-r--r--src-qt5/desktop-utils/lumina-fm/lumina-fm.pro1
3 files changed, 60 insertions, 13 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;
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h
index 94f6ba3f..7ccb5199 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.h
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.h
@@ -15,6 +15,8 @@
#include <QIcon>
//#include <QFutureWatcher>
+#include <QMediaPlayer>
+#include <LVideoSurface.h>
#include <LuminaXDG.h>
/*class FileItem{
public:
@@ -43,8 +45,9 @@ public:
private:
QString currentDir;
QFileSystemWatcher *watcher;
+ //QImage videoFrame;
bool showHidden, showThumbs;
- QStringList imageFormats, oldFiles;
+ QStringList imageFormats, videoFormats, oldFiles;
QHash<QString, QIcon> mimeIcons; //cache for quickly re-using QIcons
void loadItem(QString info, Browser *obj); //this is the main loader class - multiple instances each run in a separate thread
@@ -53,7 +56,8 @@ 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 futureFinished(QString, QImage);
public slots:
@@ -70,6 +74,8 @@ signals:
//Internal signal for the alternate threads
void threadDone(QString, QImage);
+
+ //void frameChanged();
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
index 6c340e14..6cb4a537 100644
--- a/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
+++ b/src-qt5/desktop-utils/lumina-fm/lumina-fm.pro
@@ -15,6 +15,7 @@ include(../../core/libLumina/LuminaXDG.pri)
include(../../core/libLumina/LuminaSingleApplication.pri)
include(../../core/libLumina/LuminaThemes.pri)
include(../../core/libLumina/ExternalProcess.pri)
+include(../../core/libLumina/LVideoSurface.pri)
SOURCES += main.cpp \
MainUI.cpp \
bgstack15