Proposed protocol, something like below:
red = messages from client to MC
blue = messages from MC to client
green = comments
< and > are not part of the message, it's just to indicate direction.
< HELLO { MCVersion: "33.0.15", APILevel: 1 } // greeting message from server on connection
> HI ALEXA! // client sends invalid command
< What? Unknown command // standard error message
> Nevermind...
< What? Unknown command
// client registers for all events, server says OK and immediately sends the current PLAYSTATE (could also send other events for current mode/view/state)
> SUBSCRIBE { event: "*", fields: "key" }
< OK
< EVENT { seq: 1, time: 1724945366, event: PLAYSTATE, state: PLAYING, position: 213, Key: 12345 }
// client re-registers for PLAYSTATE events with a specific field list, server says OK and resends the current PLAYSTATE
> SUBSCRIBE { event: "PLAYSTATE", fields: ["Key", "Name", "Track #", "Disc #", "Album", "Year", "Artist", "Album Artist", "Duration"] }
< OK
< EVENT { seq: 2, time: 1724945366, event: PLAYSTATE, state: PLAYING, position: 214, Key: 12345, Name: xxxx, "Track#": 1, Duration: 280, .... }
// event sent when track finishes
< EVENT { seq: 3, time: 1724945433, event: PLAYSTATE, state: STOPPED, position: 280, Key: 12345, Name: xxxx, "Track#": 1, Duration: 280, .... }
// next track starts
< EVENT { seq: 4, time: 1724945433, event: PLAYSTATE, state: PLAYING, position: 0, Key: 3453, Name: xxxx, "Track#": 2, Duration: 366, .... }
// user changes the volume
< EVENT { seq: 5, time: 1724945445, event: VOLUME, value: 100 }
// user pauses playing
< EVENT { seq: 6, time: 1724945623, event: PLAYSTATE, state: PAUSED, position: 190, Key: 3453, Name: xxxx, "Track#": 2, Duration: 366, .... }
// user switches to Theater Mode
< EVENT { seq: 7, time: 1724945630, event: VIEWMODE, mode: "THEATER" }
// user starts a track
< EVENT { seq: 8, time: 1724945787, event: PLAYSTATE, state: PLAYING, position: 0, Key: 832343, Name: xxxx, "Track#": 3, Duration: 324, .... }
// user seeks (position change)
< EVENT { seq: 9, time: 1724945809, event: PLAYSTATE, state: PLAYING, position: 120, Key: 832343, Name: xxxx, "Track#": 3, Duration: 324, .... }
...