Getting current Spotify track info through Windows media controls in C++

I want to create an application that can detect what song is currently playing on Spotify. I noticed that when I press the volume keys or pause button on my keyboard, Windows displays the track information in a popup notification. Since Spotify doesn’t provide a public API for this kind of integration, I’m wondering if there’s a way to access this media information that Windows already knows about. Is it possible to retrieve the current playing track details using C++ by tapping into whatever Windows uses to show those media controls? I’ve been searching for Windows APIs that might handle media sessions but I’m not sure which direction to go. Any suggestions on how to approach this would be really helpful.

Windows Media Transport Controls API is exactly what you need. I built something similar last year using the WinRT MediaManager class - works great for grabbing current media sessions. Check out GlobalSystemMediaTransportControlsSessionManager, it’ll enumerate all active sessions including Spotify. You’ll need C++/WinRT to interact with these APIs properly. Took me a while to nail down the async pattern, but once you get the session manager running, you can pull track title, artist, album art, and playback status. Updates happen in real-time so your app stays synced with whatever’s playing. Watch out for multiple media apps running - you’ll need to figure out which session is actually Spotify. Microsoft’s dev docs have some solid examples for basic session enumeration to get you going.

You’ll want to use the Windows Media Control API, specifically the ISystemMediaTransportControls interface. This feeds info to those popup notifications you see. The tricky part is accessing it from C++ since it’s mainly designed for UWP apps, but you can bridge this with Windows Runtime components. You’ll need the right headers and link against the Windows Runtime libraries. I’ve done something similar for a media widget project - querying the session manager periodically works way better than event listeners, which can be flaky with some apps. Just heads up though, this only works when Spotify actually publishes its media info to the system. It does most of the time but isn’t always consistent.

for sure! try looking into the WinRT MediaControl APIs. The GlobalSystemMediaTransportControlsSessionManager can help you fetch the media session info that pops up. thats what Spotify uses. it can be tricky to set up in C++, but it’s possible!