diff --git a/plugins/mpriscontrol/mpriscontrolplugin-win.cpp b/plugins/mpriscontrol/mpriscontrolplugin-win.cpp index dc4090d20..1150ab02b 100644 --- a/plugins/mpriscontrol/mpriscontrolplugin-win.cpp +++ b/plugins/mpriscontrol/mpriscontrolplugin-win.cpp @@ -86,11 +86,30 @@ void MprisControlPlugin::sendPlaybackInfo(std::variant c auto playbackInfo = player.GetPlaybackInfo(); auto playbackControls = playbackInfo.Controls(); + QString loopStatus; + switch(playbackInfo.AutoRepeatMode().Value()) { + case Windows::Media::MediaPlaybackAutoRepeatMode::List: { + loopStatus = QStringLiteral("Playlist"); + break; + } + case Windows::Media::MediaPlaybackAutoRepeatMode::Track: { + loopStatus = QStringLiteral("Track"); + break; + } + default: { + loopStatus = QStringLiteral("None"); + break; + } + } + np.set(QStringLiteral("isPlaying"), playbackInfo.PlaybackStatus() == GlobalSystemMediaTransportControlsSessionPlaybackStatus::Playing); np.set(QStringLiteral("canPause"), playbackControls.IsPauseEnabled()); np.set(QStringLiteral("canPlay"), playbackControls.IsPlayEnabled()); np.set(QStringLiteral("canGoNext"), playbackControls.IsNextEnabled()); np.set(QStringLiteral("canGoPrevious"), playbackControls.IsPreviousEnabled()); + np.set(QStringLiteral("canSeek"), playbackControls.IsPlaybackPositionEnabled()); + np.set(QStringLiteral("shuffle"), playbackInfo.IsShuffleActive().Value()); + np.set(QStringLiteral("loopStatus"), loopStatus); sendTimelineProperties(np, player); @@ -106,7 +125,9 @@ void MprisControlPlugin::sendTimelineProperties(std::variant(timelineProperties.Position() - timelineProperties.StartTime()).count()); } np.set(QStringLiteral("length"), std::chrono::duration_cast(timelineProperties.EndTime() - timelineProperties.StartTime()).count()); @@ -292,6 +313,25 @@ bool MprisControlPlugin::receivePacket(const NetworkPacket &np) player.TryChangePlaybackPositionAsync((player.GetTimelineProperties().StartTime() + position).count()).get(); } + if (np.has(QStringLiteral("setShuffle"))) + { + player.TryChangeShuffleActiveAsync(np.get(QStringLiteral("setShuffle"))); + } + + if (np.has(QStringLiteral("setLoopStatus"))) + { + QString loopStatus = np.get(QStringLiteral("setLoopStatus")); + enum class winrt::Windows::Media::MediaPlaybackAutoRepeatMode loopStatusEnumVal; + if (loopStatus == QStringLiteral("Track")) { + loopStatusEnumVal = Windows::Media::MediaPlaybackAutoRepeatMode::Track; + } else if (loopStatus == QStringLiteral("Playlist")) { + loopStatusEnumVal = Windows::Media::MediaPlaybackAutoRepeatMode::List; + } else { + loopStatusEnumVal = Windows::Media::MediaPlaybackAutoRepeatMode::None; + } + player.TryChangeAutoRepeatModeAsync(loopStatusEnumVal); + } + //Send something read from the mpris interface NetworkPacket answer(PACKET_TYPE_MPRIS); answer.set(QStringLiteral("player"), name);