I am trying to integrate the current media name/artist in my python app and I can't seem to get it to work.
I did the same thing with iTunes with almost no issues whatsoever but for some reasons I can't manage to get the correct instance of windows media player
wmp = win32com.client.gencache.EnsureDispatch("WMPlayer.OCX")
gets me a valid wmp instance but when I try to get the current media using
wmp.currentMedia
It returns nothing whatsoever and getting the volume like this:
wmp.settings.volume
returns a different volume than my actual opened windows media player volume.
Is there something I'm not aware of? I tried using WMPlayer.OCX.7 as well, but that doesn't work.
Windows Media Player supports several runnable instances. Creating the OCX in the way you're doing creates a separate instance of the player, which, of course, doesn't have any media loaded.
The usual way to find the "master" instance would be to look in the Running Object Table, but Windows Media Player doesn't do that. Instead, you need to use "remote" mode.
This isn't terribly well documented, but there's a VB.Net sample here, translated from a C# sample here. There are C++ samples in the Windows SDK, in the \Multimedia\WMP_11\cpp\RemoteSkin directory.
None of this, unfortunately, is in Python. But hopefully the existing samples will help you out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With