Commit d11f15a3 authored by Piyush Aggarwal's avatar Piyush Aggarwal 🎮
Browse files

mpriscontrolplugin: resolve AUMID to display name of the media app when possible

parent ad35ae75
Pipeline #65891 canceled with stage
...@@ -128,11 +128,18 @@ void MprisControlPlugin::updatePlayerList() { ...@@ -128,11 +128,18 @@ void MprisControlPlugin::updatePlayerList() {
for(uint32_t i = 0; i < sessions.Size(); i++) { for(uint32_t i = 0; i < sessions.Size(); i++) {
const auto player = sessions.GetAt(i); const auto player = sessions.GetAt(i);
auto playerName = player.SourceAppUserModelId();
QString name = QString::fromWCharArray(player.SourceAppUserModelId().c_str()); // try to resolve the AUMID to a user-friendly name
QString uniqueName = 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) { 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); playerList.insert(uniqueName, player);
......
...@@ -17,10 +17,12 @@ ...@@ -17,10 +17,12 @@
#include <winrt/Windows.Media.Control.h> #include <winrt/Windows.Media.Control.h>
#include <winrt/Windows.Storage.Streams.h> #include <winrt/Windows.Storage.Streams.h>
#include <winrt/Windows.Foundation.Collections.h> #include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.h>
using namespace winrt; using namespace winrt;
using namespace Windows::Media::Control; using namespace Windows::Media::Control;
using namespace Windows::Storage::Streams; using namespace Windows::Storage::Streams;
using namespace Windows::ApplicationModel;
#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") #define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment