How to get currently playing music from Spotify on Windows using C++

I want to build a C++ application that can detect what song is currently playing on Spotify. I noticed that Windows displays the track info when you use media keys or adjust volume controls. Since Spotify doesn’t offer a direct API for this, I’m wondering if there’s a way to access this media information that Windows already has access to. Has anyone found a method to retrieve the current track details like song title and artist from the Windows media session? I’ve been searching for Windows APIs that might expose this data but haven’t found the right approach yet. Any suggestions on how to capture this information programmatically would be really helpful.

The Windows Media Control API with ISystemMediaTransportControls should do what you need. You’ll access the current media session through Windows Runtime APIs - basically hooking into the system’s media transport controls that grab playbook info from apps like Spotify. Also check out the MediaManager class. It can list active media sessions and pull metadata like track titles, artists, and album art. Just heads up - your app needs the right permissions and the media app has to actually implement Windows media integration properly. I’ve used this approach on similar projects and it works, but debugging’s a pain since you’re dealing with system-level APIs.

I dealt with this same issue a few months back. Ended up using Windows 10’s Media Session API through COM interfaces. You need to access ISystemMediaTransportControlsInterop first, then grab the session manager. From there, enumerate the active media sessions until you find Spotify’s. The trickiest part? Setting up event handlers to catch track changes properly. Some apps don’t update metadata right away, so you might need polling as backup. Also heads up - this only works when Spotify’s actually playing. Paused tracks sometimes hide their metadata. The docs are all over the place, but once you’ve got the session object, pulling title and artist info is easy through DisplayUpdater properties.

u could try the GlobalSystemMediaTransportControlsSessionManager class from the Windows Runtime Media Control API. it gets the current track info from Spotify. might need C++/WinRT tho - a bit tricky but it works well!