diff options
author | Chris Xiong <chirs241097@gmail.com> | 2023-11-26 01:10:36 -0500 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2023-11-26 01:10:36 -0500 |
commit | 60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83 (patch) | |
tree | af08e5b6f7019c6f70bf3800a419ec78db140988 /qmidiplayer-desktop/qmpplugin.cpp | |
parent | 382d85b15ce9cc4580a2522b39f5dd4ce43a24b0 (diff) | |
download | QMidiPlayer-60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83.tar.xz |
The 2 year constipation. (mpris plugin)
Probably buggy as hell.
Diffstat (limited to 'qmidiplayer-desktop/qmpplugin.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index c52f486..7efd345 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -261,6 +261,16 @@ std::wstring qmpPluginAPIImpl::getWTitle() { return qmw ? qmw->getWTitle() : L""; } + +std::string qmpPluginAPIImpl::getFilePath() +{ + return qmw ? qmw->getFilePath().toString().toStdString() : ""; +} + +std::wstring qmpPluginAPIImpl::getWFilePath() +{ + return qmw ? qmw->getFilePath().toString().toStdWString() : L""; +} std::string qmpPluginAPIImpl::getChannelPresetString(int ch) { uint16_t b; @@ -290,6 +300,42 @@ void *qmpPluginAPIImpl::getMainWindow() return (void *)qmw; } +void qmpPluginAPIImpl::playbackControl(PlaybackControlCommand cmd, void *data) +{ + if (!qmw) return; + switch (cmd) + { + case PlaybackControlCommand::Pause: + qmw->setPaused(true); + break; + case PlaybackControlCommand::Play: + qmw->setPaused(false); + break; + case PlaybackControlCommand::TogglePause: + qmw->setPaused(!qmw->getPlaybackStatus().paused); + break; + case PlaybackControlCommand::Stop: + qmw->stop(); + break; + case PlaybackControlCommand::Seek: + qmw->playerSeek(*static_cast<uint32_t*>(data)); + break; + case PlaybackControlCommand::SeekAbs: + { + double t = *static_cast<double*>(data); + uint32_t p = 100. * t / (qmw->getPlaybackStatus().maxtime_ms / 1000.); + qmw->playerSeek(p); + } + break; + case PlaybackControlCommand::NextTrack: + qmw->nextTrack(); + break; + case PlaybackControlCommand::PrevTrack: + qmw->prevTrack(); + break; + } +} + void qmpPluginAPIImpl::discardCurrentEvent() { if (qmw && qmw->getPlayer()) |