aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
diff options
context:
space:
mode:
authorZackaryWelch <welch.zackary@gmail.com>2017-08-04 17:00:14 -0400
committerZackaryWelch <welch.zackary@gmail.com>2017-08-04 17:00:14 -0400
commitee494111f41ed0c5ab7b43d30f76bdb44cadfa5e (patch)
treeee54b9d089448ff593628caa342e11fb2282976c /src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
parentMerge branch 'master' of http://github.com/trueos/lumina (diff)
downloadlumina-ee494111f41ed0c5ab7b43d30f76bdb44cadfa5e.tar.gz
lumina-ee494111f41ed0c5ab7b43d30f76bdb44cadfa5e.tar.bz2
lumina-ee494111f41ed0c5ab7b43d30f76bdb44cadfa5e.zip
Added an experimental VideoSlideshow screensaver plus fixes
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
new file mode 100644
index 00000000..fdddaf93
--- /dev/null
+++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h
@@ -0,0 +1,102 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H
+#define _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H
+
+#include "global-includes.h"
+#include "BaseAnimGroup.h"
+
+class VideoSlideshow: public QPropertyAnimation{
+ Q_OBJECT
+public:
+ VideoSlideshow(QWidget *parent, QVideoWidget *videoWidget) : QPropertyAnimation(videoWidget, "pos", parent){
+ this->setKeyValueAt(0,QPoint(0,0));
+ this->setKeyValueAt(1,QPoint(0,0));
+ }
+ ~VideoSlideshow(){}
+
+};
+
+class VideoAnimation: public BaseAnimGroup{
+ Q_OBJECT
+private:
+ QString videoPath;
+ VideoSlideshow *tmp;
+ QVideoWidget *videoWidget;
+ QMediaPlayer *video;
+ QStringList videoFiles;
+ QMediaPlaylist *playlist;
+ bool multimonitor, random;
+
+private slots:
+ void startVideo() {
+ this->addAnimation(tmp);
+ tmp->setDuration(video->duration());
+ qDebug() << "Status: " << video->mediaStatus();
+ video->setPlaylist(playlist);
+ video->setVolume(100);
+ video->play();
+ }
+
+ void LoopChanged(){
+ qDebug() << "New Video";
+ if(random)
+ playlist->setCurrentIndex(qrand() % videoFiles.size());
+ else
+ playlist->setCurrentIndex(playlist->currentIndex()+1);
+ }
+
+ void stopped(){qDebug() << "Video Stopped"; videoWidget->hide();}
+
+public:
+ VideoAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){}
+
+ ~VideoAnimation(){
+ this->stop();
+ }
+
+ void LoadAnimations(){
+ canvas->setStyleSheet("background: black;");
+
+ //Load the path of the videos from the configuration file (default /usr/local/videos/)
+ videoPath = settings->value("videoSlideshow/path","/usr/local/videos/").toString();
+
+ //Set whether to copy videos on two monitors or play different videos
+ multimonitor = settings->value("videoSlideshow/multimonitor",true).toBool();
+
+ //Set whether to play random videos or in order
+ random = settings->value("videoSlideshow/random",false).toBool();
+
+ video = new QMediaPlayer(canvas, QMediaPlayer::VideoSurface);
+ videoWidget = new QVideoWidget(canvas);
+
+ tmp = new VideoSlideshow(canvas, videoWidget);
+
+ //Generate the list of files in the directory
+ videoFiles = QDir(videoPath).entryList(QDir::Files);
+ if(videoFiles.empty())
+ qDebug() << "Current video file path has no files.";
+
+ this->setLoopCount(videoFiles.size());
+
+ //Load a random initial video
+ playlist = new QMediaPlaylist();
+ for(int i = 0; i < videoFiles.size(); i++)
+ playlist->addMedia(QUrl::fromLocalFile(videoFiles[i]));
+ if(random)
+ playlist->setCurrentIndex(qrand() % videoFiles.size());
+
+ video->setVideoOutput(videoWidget);
+ videoWidget->show();
+ qDebug() << "VideoWidget Displayed";
+ connect(video, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(startVideo()));
+ connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) );
+ connect(this, SIGNAL(finished()), this, SLOT(stopped()) );
+ }
+
+};
+#endif
bgstack15