diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core/libLumina/LVideoSurface.cpp | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp | 9 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fileinfo/MainUI.h | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 97 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 2 |
5 files changed, 70 insertions, 42 deletions
diff --git a/src-qt5/core/libLumina/LVideoSurface.cpp b/src-qt5/core/libLumina/LVideoSurface.cpp index 895a3a32..bd6b2c95 100644 --- a/src-qt5/core/libLumina/LVideoSurface.cpp +++ b/src-qt5/core/libLumina/LVideoSurface.cpp @@ -12,7 +12,7 @@ bool LVideoSurface::present(const QVideoFrame &frame) { } if(frame.isValid()) { - qDebug() << "Recording Frame" << frame.pixelFormat(); + //qDebug() << "Recording Frame" << frame.pixelFormat(); QVideoFrame icon(frame); icon.map(QAbstractVideoBuffer::ReadOnly); QImage img(icon.bits(), icon.width(), icon.height(), icon.bytesPerLine(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat())); diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp index 40d2d544..0fb736d3 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp @@ -25,6 +25,7 @@ MainUI::MainUI() : QDialog(), ui(new Ui::MainUI){ SetupConnections(); player = new QMediaPlayer(this, QMediaPlayer::VideoSurface); surface = new LVideoSurface(this); + qDebug() << surface->surfaceFormat(); player->setVideoOutput(surface); player->setMuted(true); connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(setDuration(QMediaPlayer::MediaStatus))); @@ -96,7 +97,11 @@ void MainUI::LoadFile(QString path, QString type){ ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" ); //qDebug() << " - done with image"; }else if(INFO->isVideo()){ - player->setMedia(QUrl("file://"+INFO->absoluteFilePath())); + timer.start(); + QMediaResource video = QMediaResource(QUrl("file://"+INFO->absoluteFilePath())); + video.setResolution(64,64); + player->setMedia(video); + //player->setMedia(QUrl("file://"+INFO->absoluteFilePath())); player->play(); player->pause(); //Pixmap set when video is loaded in stopVideo @@ -313,6 +318,8 @@ void MainUI::getXdgCommand(QString prev){ void MainUI::stopVideo(QPixmap img) { ui->label_file_icon->setPixmap( img.scaledToHeight(64) ); player->pause(); + qDebug() << timer.elapsed(); + qDebug() << player->media().canonicalResource().resolution(); } void MainUI::setDuration(QMediaPlayer::MediaStatus status) { diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h index 5ce7b01a..3bc85aae 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h +++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.h @@ -17,6 +17,7 @@ #include <QMediaPlayer> #include <LuminaXDG.h> #include <LVideoSurface.h> +#include <QElapsedTimer> namespace Ui{ class MainUI; }; @@ -38,6 +39,7 @@ private: LVideoSurface *surface; QMediaPlayer *player; bool flag; + QElapsedTimer timer; bool canwrite; bool terminate_thread; //flag for terminating the GetDirSize task 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 |