Hi, I’m a Python Newbie and I wrote some code to collect info about the song that is being played on Mopidy.
The problem is that I need to know when the song starts. Can anyone show me an example of mopidy.core.CoreListener?
I need something like this:
info() # where info() is my function
Thank you Jodal. I’m not sure if I understood the code. But mostly it fetchs informations about the song if I’m not wrong. But I don’t see where the code “knows” that the track is changed. That’s the only thing I need. Something that tells me “Hey, I started playing a new track, you can now run your code”.
That code knows that the track is changed because that method is only called by Mopidy when a track starts playback. For that call from Mopidy to your extension to happen, you must:
- make a frontend extension,
- with an actor class, and
- that actor class must subclass
For step 1, please read https://docs.mopidy.com/en/latest/extensiondev/ in general.
For step 2 and 3, please read https://docs.mopidy.com/en/latest/extensiondev/#example-frontend for a specific example.
The Mopidy-Scrobbler extension also works as an example of all of this.
Hi @jodal thanks for that example, works a treat! I’m still getting my head around Python, so Mopidy-Scrobbler is a great example to work from.