aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpmainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-24 19:52:08 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-24 19:52:08 +0800
commitded6dd1c8f7cbe2991e90f69f95730b39eaa95cf (patch)
tree46f55ade709960f4407b836432b76901d00aa693 /qmidiplayer-desktop/qmpmainwindow.cpp
parentb059dd6fa25ad50f549cb1384042b07b6cfe06bf (diff)
downloadQMidiPlayer-ded6dd1c8f7cbe2991e90f69f95730b39eaa95cf.tar.xz
Add seeking with arrow buttons in visualization.
Diffstat (limited to 'qmidiplayer-desktop/qmpmainwindow.cpp')
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index de15412..73724ec 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -425,7 +425,7 @@ void qmpMainWindow::on_hsTimer_sliderReleased()
}
else
{
- if(stopped){ui->hsTimer->setValue(0);}return;
+ if(stopped){ui->hsTimer->setValue(0);return;}
player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value());
offset=ui->hsTimer->value()/100.*player->getFtime();
char ts[100];
@@ -434,6 +434,30 @@ void qmpMainWindow::on_hsTimer_sliderReleased()
}
}
+uint32_t qmpMainWindow::getPlaybackPercentage(){return ui->hsTimer->value();}
+void qmpMainWindow::playerSeek(uint32_t percentage)
+{
+ if(percentage>100)percentage=100;
+ if(percentage<0)percentage=0;
+ if(playing)
+ {
+ if(percentage==100){on_pbNext_clicked();return;}
+ player->setTCeptr(player->getStamp(percentage),percentage);
+ player->playerPanic();ui->hsTimer->setValue(percentage);
+ offset=percentage/100.*player->getFtime();
+ st=std::chrono::steady_clock::now();
+ }
+ else
+ {
+ if(stopped){ui->hsTimer->setValue(0);return;}
+ player->setTCeptr(player->getStamp(percentage),percentage);
+ offset=percentage/100.*player->getFtime();ui->hsTimer->setValue(percentage);
+ char ts[100];
+ sprintf(ts,"%02d:%02d",(int)(offset)/60,(int)(offset)%60);
+ ui->lbCurTime->setText(ts);
+ }
+}
+
void qmpMainWindow::on_vsMasterVol_valueChanged()
{
if(!stopped)player->setGain(ui->vsMasterVol->value()/250.);