mpriscontrolplugin: resolve AUMID to display name of the media app when possible
This commit is contained in:
parent
ad35ae75d9
commit
d11f15a3e6
2 changed files with 12 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -17,10 +17,12 @@
|
|||
#include <winrt/Windows.Media.Control.h>
|
||||
#include <winrt/Windows.Storage.Streams.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace Windows::Media::Control;
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Windows::ApplicationModel;
|
||||
|
||||
#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")
|
||||
|
||||
|
|
Loading…
Reference in a new issue