INTERACT FORUM

Please login or register.

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

Author Topic: [Feature Request] Function to return current play state  (Read 285 times)

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2739
[Feature Request] Function to return current play state
« on: January 06, 2025, 04:27:37 am »

Hi @Matt,

Is there a way to get the current play state in MC? If not, a new function would be nice, something like this:

PlayState(mode, fields) - get information about the current playing status and track

The function returns a list with the current state, track position, current playlist info, and the requested fields for the playing track (regardless of which file is currently in the execution context).

fields: list of fields to return for currently playing track
Mode:
   0 = current playing status; position in seconds; FileKey
   1 = current playing status; position in seconds; FileKey; PlayListId; PlayListName; Playlist Position
   2 = requested Fields for current track
   3 = 1+2 combined

Playing status: PLAYING | PAUSED | STOPPED

Examples:
PlayState(0)
PLAYING;125;452345

PlayState(1)
PLAYING;125;452345;2897346;Best of 90's;5

PlayState(2, Key;Title;Artist;Album;Year)
452345;Until It Sleeps;Metallica;Load;1996

PlayState(3, Key;Title;Artist;Album;Year)
PLAYING;125;452345;2897346;Best of 90's;5;Until It Sleeps;Metallica;Load;1996

Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2739
Re: [Feature Request] Function to return current play state
« Reply #1 on: January 06, 2025, 04:36:43 am »

Some meta-fields could also be added for similar usage:

[PlayStatus] = PLAYING / PAUSED / STOPPED
[PlayPosition] = 125
[PlayFile] = 452345  (can be used with Field() function to get additional info for this file)
[PlayPlaylist] = 2897346;Best of 90's;5
[PlaylistSeq] = 5  (current track Seq in playlist)
[PlaylistPosition] = 765   (total elapsed time in current playlist = sum of previous tracks plus current position)
[PlaylistDuration] = 4666 (total playlist time)
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10991
Re: [Feature Request] Function to return current play state
« Reply #2 on: January 06, 2025, 05:00:40 am »

Expressions aren't in a position to really access playback state, playback state is in a fragile position with threaded access, and expressions running at any place in the app would likely result in a bunch of issues.
Logged
~ nevcairiel
~ Author of LAV Filters

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2739
Re: [Feature Request] Function to return current play state
« Reply #3 on: January 06, 2025, 05:13:06 am »

Thanks Hendrik.
Bummer. Couldn't the playing thread raise events or update a shared mem structure once or twice a second?
Logged
Pages: [1]   Go Up