aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2017-10-21 19:19:28 -0400
committerZackaryWelch <welch.zackary@gmail.com>2017-10-21 19:19:28 -0400
commitb4bb314391b9d363944b8de91ea2c660675fabc6 (patch)
tree0a2f9ad903d003aecd27a84697605a9d21225086
parentFinished video thumbnails and roll over playback for lumina-fm and (diff)
downloadlumina-b4bb314391b9d363944b8de91ea2c660675fabc6.tar.gz
lumina-b4bb314391b9d363944b8de91ea2c660675fabc6.tar.bz2
lumina-b4bb314391b9d363944b8de91ea2c660675fabc6.zip
Added some testing code for issues with directories having >10 videos
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.cpp34
-rw-r--r--src-qt5/core/libLumina/LVideoLabel.h1
2 files changed, 31 insertions, 4 deletions
diff --git a/src-qt5/core/libLumina/LVideoLabel.cpp b/src-qt5/core/libLumina/LVideoLabel.cpp
index b90cff66..af23330c 100644
--- a/src-qt5/core/libLumina/LVideoLabel.cpp
+++ b/src-qt5/core/libLumina/LVideoLabel.cpp
@@ -1,4 +1,5 @@
#include "LVideoLabel.h"
+#include <QCoreApplication>
LVideoLabel::LVideoLabel(QString file, QWidget *parent) : QLabel(parent) {
thumbnail = QPixmap();
@@ -27,13 +28,14 @@ void LVideoLabel::initializeBackend(){
mediaPlayer->setMedia(QUrl::fromLocalFile(filepath));
mediaPlayer->play();
- mediaPlayer->pause();
this->connect(surface, SIGNAL(frameReceived(QPixmap)), this, SLOT(stopVideo(QPixmap)));
+ this->connect(mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stateChanged(QMediaPlayer::State)));
this->connect(mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(setDuration(QMediaPlayer::MediaStatus)));
this->connect(this, SIGNAL(rollOver()), surface, SLOT(switchRollOver()));
}
+
void LVideoLabel::stopVideo(QPixmap pix) {
if(!entered) {
emit frameReceived(pix);
@@ -46,19 +48,42 @@ void LVideoLabel::stopVideo(QPixmap pix) {
}
}
+void LVideoLabel::stateChanged(QMediaPlayer::State state) {
+ //qDebug() << state;
+}
+
void LVideoLabel::setDuration(QMediaPlayer::MediaStatus status) {
- if(status == QMediaPlayer::BufferedMedia) {
+ //qDebug() << status;
+ if(status == QMediaPlayer::BufferedMedia && !entered) { //Set duration in the middle to capture the thumbnail
mediaPlayer->setPosition(mediaPlayer->duration() / 2);
mediaPlayer->play();
- }
+ }else if(status == QMediaPlayer::EndOfMedia && entered) { //Loop back to the beginning if playback started and at the end of the video
+ mediaPlayer->setPosition(0);
+ mediaPlayer->play();
+ }else if(status == QMediaPlayer::InvalidMedia){
+ mediaPlayer->stop();
+ mediaPlayer->play();
+ }/*else if(status == QMediaPlayer::LoadingMedia) {
+ mediaPlayer->pause();
+ QTimer timer;
+ timer.setSingleShot(true);
+ timer.setInterval(300);
+ timer.start();
+ qDebug() << "Timer Started" << timer.remainingTime();
+ while(timer.isActive()) QCoreApplication::processEvents(QEventLoop::AllEvents, 5);
+ qDebug() << "Timer Finished" << timer.remainingTime();
+ mediaPlayer->setPosition(0);
+ mediaPlayer->play();
+ }*/
}
void LVideoLabel::resizeEvent(QResizeEvent *event) {
- if(!thumbnail.isNull())
+ if(!thumbnail.isNull()) //Resize the current pixmap to match the new size
this->setPixmap(thumbnail.scaled(this->size(),Qt::IgnoreAspectRatio));
QLabel::resizeEvent(event);
}
+//Start playing the video from the beginning when the mouse enters the label
void LVideoLabel::enterEvent(QEvent *event) {
entered=true;
emit rollOver();
@@ -67,6 +92,7 @@ void LVideoLabel::enterEvent(QEvent *event) {
QWidget::enterEvent(event);
}
+//Stop the video and set the thumbnail back to the middle of the video when the mouse leaves the label
void LVideoLabel::leaveEvent(QEvent *event) {
entered=false;
mediaPlayer->setPosition(mediaPlayer->duration() / 2);
diff --git a/src-qt5/core/libLumina/LVideoLabel.h b/src-qt5/core/libLumina/LVideoLabel.h
index 8c544b16..f368c1a8 100644
--- a/src-qt5/core/libLumina/LVideoLabel.h
+++ b/src-qt5/core/libLumina/LVideoLabel.h
@@ -27,6 +27,7 @@ class LVideoLabel : public QLabel{
void initializeBackend();
void stopVideo(QPixmap);
void setDuration(QMediaPlayer::MediaStatus);
+ void stateChanged(QMediaPlayer::State);
private:
QMediaPlayer *mediaPlayer;
bgstack15