diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h | 73 |
1 files changed, 20 insertions, 53 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 index cc3c1b83..9c52c447 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/VideoSlideshow.h @@ -4,58 +4,22 @@ // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== -#ifndef _LUMINA_DESKTOP_SCREEN_SAVER_VIDEOSLIDESHOW_ANIMATION_H +#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)); - this->setDuration(1000000); - this->setLoopCount(-1); - } - ~VideoSlideshow(){} - -}; - class VideoAnimation: public BaseAnimGroup{ Q_OBJECT private: QString videoPath; - VideoSlideshow *tmp; QVideoWidget *videoWidget; QMediaPlayer *video; QStringList videoFiles; - bool multimonitor; + //bool multimonitor; private slots: - void startVideo(QAbstractAnimation::State state) { - qDebug() << "Status: " << video->mediaStatus() << "New Animation State:" << state; - if(state==QAbstractAnimation::Running){ - video->setVolume(100); - video->play(); - } - if(state==QAbstractAnimation::Stopped && video->state()!=QMediaPlayer::StoppedState){ - video->stop(); - } - } - - void stopVideo() { - if(video->state() == QMediaPlayer::StoppedState) { - qDebug() << "Stopping Animation"; - //this->deleteLater(); - videoWidget->hide(); - tmp->stop(); - //tmp->deleteLater(); - videoWidget->deleteLater(); - video->deleteLater(); - } - } public: VideoAnimation(QWidget *parent, QSettings *set) : BaseAnimGroup(parent, set){} @@ -72,32 +36,35 @@ public: if(!videoPath.endsWith("/")){ videoPath.append("/"); } //Set whether to copy videos on two monitors or play different videos - multimonitor = settings->value("videoSlideshow/multimonitor",true).toBool(); + //multimonitor = settings->value("videoSlideshow/multimonitor",true).toBool(); + //Set up the VideoWidget video = new QMediaPlayer(canvas, QMediaPlayer::VideoSurface); videoWidget = new QVideoWidget(canvas); + video->setVideoOutput(videoWidget); videoWidget->setGeometry(QRect(QPoint(0,0), canvas->size())); - - tmp = new VideoSlideshow(canvas, videoWidget); - this->addAnimation(tmp); //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(1); - - QUrl url = QUrl::fromLocalFile(videoPath+videoFiles[qrand() % videoFiles.size()]); - video->setMedia(url); - qDebug() << url; - video->setVideoOutput(videoWidget); + //Loading a random file from a directory + QDesktopWidget *dw = new QDesktopWidget(); + QMediaPlaylist *playlist = new QMediaPlaylist(); + for(int i = 0; i < videoFiles.size(); i++) + playlist->addMedia(QUrl::fromLocalFile(videoPath+videoFiles[i])); + qsrand(QTime::currentTime().msec()); + playlist->setCurrentIndex(qrand() % videoFiles.size()); + playlist->setPlaybackMode(QMediaPlaylist::Random); videoWidget->show(); - - qDebug() << "VideoWidget Displayed"; - connect(tmp, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), this, SLOT(startVideo(QAbstractAnimation::State)) ); - //connect(video, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(startVideo()) ); - connect(video, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stopVideo()) ); + video->setPlaylist(playlist); + //Only play sound for one monitor to prevent messed up audio + if(dw->screenNumber(canvas) == 0) + video->setVolume(100); + else + video->setVolume(0); + video->play(); } }; |