Hello!
I'm dealing with catching changes in the 'Now playing' list as events so I can change my display accordingly.
The playbackState fires when one track ends and the next one starts playing. The nowPlayingModified fires when I add a new track to the player. My problem is that I cannot find which events will fire when I remove a track or I move a track within the player. Are there events for those situations?
Thank you in advance,
Marcelo
Sending Player info to a window
Moderators: jiri, drakinite, Addon Administrators
Re: Sending Player info to a window
Haven't tested to make sure, but both should fire with nowPlayingModified: https://www.mediamonkey.com/docs/api/fi ... ngModified
Re: Sending Player info to a window
Thank you for the prompt response. I think it doesn't work. I hope I'm wrong. I'll try again.drakinite wrote: ↑Mon Jul 04, 2022 2:39 pm Haven't tested to make sure, but both should fire with nowPlayingModified: https://www.mediamonkey.com/docs/api/fi ... ngModified
Meanwhile, I'm using SetTimeout to send a function that calls itself recursively and checks for changes in the player.
Thanks,
Marcelo
Re: Sending Player info to a window
Hi Marcelo,
thanks for reporting, it really fails to work for re-order and deletions.
To be fixed as https://www.ventismedia.com/mantis/view.php?id=19266
Workaround is to listen 'change' event on app.player.getSongList()
https://www.mediamonkey.com/docs/api/cl ... etSongList
thanks for reporting, it really fails to work for re-order and deletions.
To be fixed as https://www.ventismedia.com/mantis/view.php?id=19266
Workaround is to listen 'change' event on app.player.getSongList()
https://www.mediamonkey.com/docs/api/cl ... etSongList
Re: Sending Player info to a window
Thank you for the response!
Can you show me how the workaround line looks?
Maybe something like:
app.listen(app.player.getSongList(), 'change', eventFunction);
Thanks,
Marcelo
Can you show me how the workaround line looks?
Maybe something like:
app.listen(app.player.getSongList(), 'change', eventFunction);
Thanks,
Marcelo
Re: Sending Player info to a window
Yep. Though it may be a better idea to store the list as a variable first.
(I haven't tested that code, but it should work)
Code: Select all
let thisSongList = app.player.getSongList();
app.listen(thisSongList, 'change', function (changeType) {
// do stuff
});
Re: Sending Player info to a window
Maybe I understand now. So I'm actually checking the change in a list, not an event as I'm used to. Is it right?
And in that case, I have to set a loop where the list variable gets the new list and the "change event" does the rest.
Am I seeing it right?
Thank you!
And in that case, I have to set a loop where the list variable gets the new list and the "change event" does the rest.
Am I seeing it right?
Thank you!
Re: Sending Player info to a window
No, no need for a loop. I was just giving a general coding suggestion. app.listen(app.player.getSongList(), ...) is still valid; but if you want to access thisSongList inside your event handler, you won't have to do app.player.getSongList() multiple times.
Code: Select all
app.listen(app.player.getSongList(), 'change', function (changeType) {
if (changeType === undefined) {
console.log('Song list has been rearranged');
}
})
Re: Sending Player info to a window
Thank you!
I think I need to do some homework.
I think I need to do some homework.