aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp22
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp1
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp5
-rw-r--r--qmidiplayer-desktop/qmpplugin.hpp1
4 files changed, 24 insertions, 5 deletions
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index 69a0ba9..05b7ec3 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -371,7 +371,8 @@ void qmpMainWindow::switchTrack(QString s, bool interrupt)
sprintf(ts, "%02d:%02d", (int)player->getFtime() / 60, (int)player->getFtime() % 60);
ui->lbFinTime->setText(ts);
player->playerInit();
- invokeCallback("main.start", nullptr);
+ PlaybackStatus ps = getPlaybackStatus();
+ invokeCallback("main.start", &ps);
internalfluid->setGain(ui->vsMasterVol->value() / 250.);
efxw->sendEfxChange();
playerTh = new std::thread([this]
@@ -525,7 +526,8 @@ void qmpMainWindow::on_pbPlayPause_clicked()
sprintf(ts, "%02d:%02d", (int)player->getFtime() / 60, (int)player->getFtime() % 60);
ui->lbFinTime->setText(ts);
player->playerInit();
- invokeCallback("main.start", nullptr);
+ PlaybackStatus ps = getPlaybackStatus();
+ invokeCallback("main.start", &ps);
internalfluid->setGain(ui->vsMasterVol->value() / 250.);
efxw->sendEfxChange();
playerTh = new std::thread([this]
@@ -556,7 +558,8 @@ void qmpMainWindow::on_pbPlayPause_clicked()
player->setResumed();
}
player->setTCpaused(!playing);
- invokeCallback("main.pause", nullptr);
+ PlaybackStatus ps = getPlaybackStatus();
+ invokeCallback("main.pause", &ps);
}
ui->pbPlayPause->setIcon(QIcon(getThemedIcon(playing ? ":/img/pause.svg" : ":/img/play.svg")));
}
@@ -594,7 +597,8 @@ void qmpMainWindow::on_hsTimer_sliderReleased()
sprintf(ts, "%02d:%02d", (int)(offset) / 60, (int)(offset) % 60);
ui->lbCurTime->setText(ts);
}
- invokeCallback("main.seek", nullptr);
+ PlaybackStatus ps = getPlaybackStatus();
+ invokeCallback("main.seek", &ps);
}
uint32_t qmpMainWindow::getPlaybackPercentage()
@@ -607,7 +611,6 @@ void qmpMainWindow::playerSeek(uint32_t percentage)
percentage = 100;
if (percentage < 0)
percentage = 0;
- invokeCallback("main.seek", nullptr);
if (playing)
{
if (percentage == 100)
@@ -635,6 +638,15 @@ void qmpMainWindow::playerSeek(uint32_t percentage)
sprintf(ts, "%02d:%02d", (int)(offset) / 60, (int)(offset) % 60);
ui->lbCurTime->setText(ts);
}
+ PlaybackStatus ps = getPlaybackStatus();
+ invokeCallback("main.seek", &ps);
+}
+
+PlaybackStatus qmpMainWindow::getPlaybackStatus()
+{
+ std::chrono::duration<double> elapsed =
+ std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::steady_clock::now() - st);
+ return {!playing, uint64_t((elapsed.count() + offset) * 1000), uint64_t(player->getFtime() * 1000), player->getTick(), player->getMaxTick()};
}
void qmpMainWindow::on_vsMasterVol_valueChanged()
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index 47a29f6..eb36ba8 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -228,6 +228,7 @@ public:
std::wstring getWTitle();
uint32_t getPlaybackPercentage();
void playerSeek(uint32_t percentage);
+ PlaybackStatus getPlaybackStatus();
int parseArgs();
void registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable);
void unregisterFunctionality(std::string name);
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index ca851ee..c52f486 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -213,6 +213,11 @@ uint32_t qmpPluginAPIImpl::getCurrentPlaybackPercentage()
{
return qmw ? qmw->getPlaybackPercentage() : 0;
}
+
+PlaybackStatus qmpPluginAPIImpl::getPlaybackStatus()
+{
+ return qmw ? qmw->getPlaybackStatus() : PlaybackStatus{false, 0, 0, 0, 0};
+}
int qmpPluginAPIImpl::getChannelCC(int ch, int cc)
{
return qmw && qmw->getPlayer() ? qmw->getPlayer()->getCC(ch, cc) : 0;
diff --git a/qmidiplayer-desktop/qmpplugin.hpp b/qmidiplayer-desktop/qmpplugin.hpp
index 778f90f..b7a5e06 100644
--- a/qmidiplayer-desktop/qmpplugin.hpp
+++ b/qmidiplayer-desktop/qmpplugin.hpp
@@ -37,6 +37,7 @@ public:
uint32_t getMaxPolyphone();
uint32_t getCurrentTimeStamp();
uint32_t getCurrentPlaybackPercentage();
+ PlaybackStatus getPlaybackStatus();
int getChannelCC(int ch, int cc);
int getChannelPreset(int ch);
void playerSeek(uint32_t percentage);