I am currently working on a player design. Without going into details I have two main layers 1. Playback services 2. User Interface. Playback services consist mainly of Player service and Browser Service. They communicate over REST API. User Interface subscribes to various services. I want to keep the services as stateless as possible.
I am a bit confused about how to keep the services stateless. Regarding browser it is straightforward. I get a path to navigate, I retrieve the results and publish them and the browser service is stateless again.
However, I don't understand how can I make the player stateless! Lets take the concrete use-cases: Various operations like play, resume, pause etc. can be acted upon only if the player has a certain state. For example, we can't start the playback if there is no track loaded earlier. Similarly, stop makes sense if we are already playing.
Is it the responsibility of the clients to look for the states as they are subscribed to the player and if the player is not in the right state then they have to first bring it into the state that a certain operation makes sense?