summaryrefslogtreecommitdiffstats
path: root/videoviewer.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-08-26 20:52:01 +0200
committerArno <arno@disconnect.de>2018-08-26 20:52:01 +0200
commitb91500859bcc2e2aeef098cded9d552c9c15a4b0 (patch)
tree620d4311cca3447f368d53af0c45a9ed2d524489 /videoviewer.cpp
parent68ee6a0ec973940eb4f799b00f6518a902cbc4e5 (diff)
downloadSheMov-b91500859bcc2e2aeef098cded9d552c9c15a4b0.tar.gz
SheMov-b91500859bcc2e2aeef098cded9d552c9c15a4b0.tar.bz2
SheMov-b91500859bcc2e2aeef098cded9d552c9c15a4b0.zip
Fix next and previous in VideoViewer
The QMediaPlayList implementations return -1 after the last valid index. Fix it by implementing a homebrewed version...
Diffstat (limited to 'videoviewer.cpp')
-rw-r--r--videoviewer.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/videoviewer.cpp b/videoviewer.cpp
index 5430e9f..0c90e97 100644
--- a/videoviewer.cpp
+++ b/videoviewer.cpp
@@ -38,9 +38,19 @@ void VideoViewer::keyPressEvent(QKeyEvent *e){
qint64 pos = mPlayer->position();
mPlayer->setPosition(pos - 60000 < 0 ? 0 : pos - 60000);
}else if(keyNum == Qt::Key_N){
- mPlayer->playlist()->next();
+ int mediaCount = mPlayer->playlist()->mediaCount();
+ int nextIndex = mPlayer->playlist()->currentIndex() + 1;
+ if(nextIndex >= mediaCount){
+ nextIndex = 0;
+ }
+ mPlayer->playlist()->setCurrentIndex(nextIndex);
}else if(keyNum == Qt::Key_P){
- mPlayer->playlist()->previous();
+ int mediaCount = mPlayer->playlist()->mediaCount();
+ int prevIndex = mPlayer->playlist()->currentIndex() - 1;
+ if(prevIndex < 0){
+ prevIndex = mediaCount - 1;
+ }
+ mPlayer->playlist()->setCurrentIndex(prevIndex);
}else if(keyNum == Qt::Key_M){
mPlayer->setMuted(mPlayer->isMuted() ? false : true);
}