INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: How to detect what playlist is "current"  (Read 2015 times)

dhiggins

  • Regular Member
  • World Citizen
  • ***
  • Posts: 126
How to detect what playlist is "current"
« on: September 04, 2008, 11:30:38 pm »

I see the CurPlayList property off the main MC object, but there's no identification properties that go along with it (like the name or ID of the playlist).

I thought I could grab the EventData3 off the Playlist Files Changed event, and just scan for the playlist, but doing that always ends up pointing as some hidden, arbitrarily named playlist (usually, they're named with a Date and time) instead of the playlist that is really the current playlist. Not sure what's up with that.

Am I just missing something obvious?

Thanks
Darin
Logged

davjand

  • Junior Woodchuck
  • **
  • Posts: 58
Re: How to detect what playlist is "current"
« Reply #1 on: September 05, 2008, 06:08:41 pm »

I'm pretty sure that the current playlist is the Now Playing playlist.
I don't know if you've ever noticed but when you clear what is currently playing, MC will generate a group of recent now playing playlists named with date and time so thats probably where the date and time comes from!

Hope this helps
Logged

dhiggins

  • Regular Member
  • World Citizen
  • ***
  • Posts: 126
Re: How to detect what playlist is "current"
« Reply #2 on: September 05, 2008, 10:09:19 pm »

Hi

Thanks for the reply.

I hadn't thought about the nowplaying list, but I just checked it out. There's no "Now playing" object, but there is the GetCurPlaylist method.

The prob is, the playlist object it returns doesn't expose a "name" property, or an ID I could use to look up the actual playlist object to get it's name.

I scanned through all the Playlists you get when you call GetPlaylists, but none of them came up "Now Playing" and even if one did, that wouldn't indicate which actual play list was being played.

But I do see what you're saying about the date and time named playlists, that makes some sense now.

Still looking, but thanks for the info!

Darin
Logged

Doof

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5908
  • Farm Animal Stupid
Re: How to detect what playlist is "current"
« Reply #3 on: September 06, 2008, 12:29:21 am »

The only "current playlist" is Playing Now. MC doesn't play a playlist the same way other players do. It just copies the contents of the selected playlists into Playing Now and then plays Playing Now. A file can be added to Playing Now and it doesn't get added to any playlists even if Playing Now was initially seeded by a playlist, for instance. GetCurPlaylist returns the contents of Playing Now, nothing more.

Also, Playing Now isn't a playlist in the same sense that the other playlists are, so looping through and getting a list of playlists won't ever return Playing Now. Playing Now is it's own object.

If you read through the automation docs, you'll see that GetCurPlaylist() returns an MJCurPlaylistAutomation object, which represents Playing Now. GetPlaylists() returns an MJPlaylistsAutomation object which represents all the other playlists, and once you have an MJPlaylistsAutomation object, one of its methods is GetPlaylists(n), which returns an object that represents the playlist specified by n. To get to the files within that playlist you have to dig yet one more level down and call GetFiles() which will finally return an MJFilesAutomation object which represents the collection of files within that playlist.

I just skimmed the docs and couldn't see any way to determine which playlist was sent to Playing Now. I suppose you could brute-force it and grab a list of files in Playing Now and compare it to each playlist to try to determine which playlist is being played, but it's not foolproof by any stretch.
Logged

dhiggins

  • Regular Member
  • World Citizen
  • ***
  • Posts: 126
Re: How to detect what playlist is "current"
« Reply #4 on: September 06, 2008, 09:03:29 am »

Hi Doof

Thanks for the info. Yeah, I finally realized about midnight last night that that's what's going on (copying a playlist to Now Playing), which then explains why there's two different objects (the curplaylist and the normal playlists) to represent playlists...

I came to the same conclusion as you about scanning the playlists looking for the one that's playing. I think I've about got something going there...

The reason I'm looking to do this is I'd like to be able to react to a remote control keypress, but there's nothing I can find that allows a plugin to monitor remote control activity.

The only thing I've found so far is to add a few commands to the remote configuration, using the "Play Playlist" option, then specify a playlist that has just  few arbitrary songs in it.

I name the playlist something like "Command1", "Command2" etc.

Then, each time a track starts playing, I can check what the "Current Playlist" is and if it's one of the "command" playlists, I can stop playing and do whatever I need to based on the command, then resume playing (that last part is still up in the air<g>)

Also for switching play lists, it'd be nice to be able to "announce" the playlist when I switch (so I know I got the right one).

The whole thing would be piles simpler if the remote plugin sourced some events <sigh>

But, hey, MC is pretty sweet all things considered so this is pretty minor.
Logged
Pages: [1]   Go Up