Try this api using winrt:
The enum options are listed here, but you can use mediaIs("PAUSED")
, mediaIs("PLAYING")
ect...
import asyncio, winrt.windows.media.control as wmc
async def getMediaSession():
sessions = await wmc.GlobalSystemMediaTransportControlsSessionManager.request_async()
session = sessions.get_current_session()
return session
def mediaIs(state):
session = asyncio.run(getMediaSession())
if session == None:
return False
return int(wmc.GlobalSystemMediaTransportControlsSessionPlaybackStatus[state]) == session.get_playback_info().playback_status #get media state enum and compare to current main media session state
There are heaps more useful winrt APIs to control media on windows too here.