Skip to content

Instantly share code, notes, and snippets.

@CarterLi
Last active June 10, 2024 11:25
Show Gist options
  • Save CarterLi/ff88fd063771341e9386593943e934e8 to your computer and use it in GitHub Desktop.
Save CarterLi/ff88fd063771341e9386593943e934e8 to your computer and use it in GitHub Desktop.
GlobalSystemMediaTransportControlsSessionManager
#include <winrt/windows.media.control.h>
#include <winrt/windows.media.playback.h>
#include <winrt/Windows.Foundation.h>
#include <stdio.h>
int main()
{
using namespace winrt::Windows::Media;
setlocale(LC_ALL, ".UTF8");
auto manager = Control::GlobalSystemMediaTransportControlsSessionManager::RequestAsync()
.get();
if (!manager)
return 1;
auto session = manager.GetCurrentSession();
if (!session)
return 2;
auto playbackInfo = session.GetPlaybackInfo();
auto mediaProps = session
.TryGetMediaPropertiesAsync()
.get();
if (!mediaProps)
return 3;
wprintf(L"%s\n", session.SourceAppUserModelId().data());
wprintf(L"%s - %s\n", mediaProps.Artist().data(), mediaProps.Title().data());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment