Last active
June 10, 2024 11:25
-
-
Save CarterLi/ff88fd063771341e9386593943e934e8 to your computer and use it in GitHub Desktop.
GlobalSystemMediaTransportControlsSessionManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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