diff --git a/plugins/mpriscontrol/mpriscontrolplugin-win.cpp b/plugins/mpriscontrol/mpriscontrolplugin-win.cpp index f41446370..f10ced96a 100644 --- a/plugins/mpriscontrol/mpriscontrolplugin-win.cpp +++ b/plugins/mpriscontrol/mpriscontrolplugin-win.cpp @@ -128,11 +128,18 @@ void MprisControlPlugin::updatePlayerList() { for(uint32_t i = 0; i < sessions.Size(); i++) { const auto player = sessions.GetAt(i); + auto playerName = player.SourceAppUserModelId(); - QString name = QString::fromWCharArray(player.SourceAppUserModelId().c_str()); - QString uniqueName = name; + // try to resolve the AUMID to a user-friendly name + try { + playerName = AppInfo::GetFromAppUserModelId(playerName).DisplayInfo().DisplayName(); + } catch (winrt::hresult_error e) { + qCDebug(KDECONNECT_PLUGIN_MPRIS) << QString::fromWCharArray(playerName.c_str()) << "doesn\'t have a valid AppUserModelID! Sending as-is.."; + } + + QString uniqueName = QString::fromWCharArray(playerName.c_str()); for (int i = 2; playerList.contains(uniqueName); ++i) { - uniqueName = name + QStringLiteral(" [") + QString::number(i) + QStringLiteral("]"); + uniqueName += QStringLiteral(" [") + QString::number(i) + QStringLiteral("]"); } playerList.insert(uniqueName, player); diff --git a/plugins/mpriscontrol/mpriscontrolplugin-win.h b/plugins/mpriscontrol/mpriscontrolplugin-win.h index 2d975421d..562283be4 100644 --- a/plugins/mpriscontrol/mpriscontrolplugin-win.h +++ b/plugins/mpriscontrol/mpriscontrolplugin-win.h @@ -17,10 +17,12 @@ #include #include #include +#include using namespace winrt; using namespace Windows::Media::Control; using namespace Windows::Storage::Streams; +using namespace Windows::ApplicationModel; #define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")