Updated Playback states & service states (markdown)

Nite 2021-05-04 13:32:27 +02:00
parent 1023a9a7cd
commit e3b9d75a14
1 changed files with 12 additions and 6 deletions

@ -1,4 +1,5 @@
* **Service running**: Service is running, but startForeground was not called.
* **Service running**: Service is running, but startForeground was not called. (Actually on current APIs this state would result in an Exception. MediaPlayerService is started with startForegroundService, and foreground services must call startForeground with a notification in ~5 secs. [Also see this.](https://stackoverflow.com/questions/44425584/context-startforegroundservice-did-not-then-call-service-startforeground))
* **Service is running in Background**: Service is running, but stopForeground was called.
* **Service as Foreground**: Service is running, startForeground was called, Notification is shown
* **stopForeground**: If we exit foreground, we can specify a flag, whether to remove, or to detach the notification. <br>If detached, the notification will stay, even when the service has been de-foregrounded
* **registerMediaButtonReceiver**: With the newer architecture this is only possible if we have a service
@ -8,9 +9,14 @@
| Condition | Playback State | Service running | Service has notification | Service as Foreground | stop Foreground() | register MediaButtonReceiver |
|----------------------------------|----------------|-----------------|--------------------------|-----------------------|--------------------------------------------|--------------------------------------|
| App starts, no resumable track | STOPPED | ? | ✗ | ✗ | ✗ | Only possible if service is running. |
| App starts, with resumable track | PAUSED | ✓ | ✓ | ? | ✗ | ✓ |
| App starts, no resumable track | STOPPED | | ✗ | ✗ | ✗ | Only possible if service is running. |
| App starts, with resumable track (1) | PAUSED | ✓ | ✓ | | ✗ | ✓ |
| Active playing | PLAYING | ✓ | ✓ | ✓ | ✗ | ✓ |
| Paused by the user | PAUSED | ✓ | ✓ | ? | stopForeground(DETACH) | ✓ |
| Playback has finished / idle | STOPPED | ? | ? | ? | stopForeground() or stopForeground(DETACH) | Only possible if service is running. |
| | | | | | | |
| Paused by the user | PAUSED | ✓ | ✓ | (2) | stopForeground(DETACH) | ✓ |
| Playback has finished / idle (3) | STOPPED | ✗ | ✗ | ✗ | stopForeground() or stopForeground(DETACH) | Only possible if service is running. |
| | | | | | | |
(1): This is the current logic, but #426 is about changing this. After #426 is implemented, the App will start in a simple STOPPED state.
(2): The current logic is that in the paused state the service remains in the foreground. The notification can't be dismissed, only with the "x".
The desired operation would be possibly that the service must detach the notification and go to background here. The notification can be dismissed by the user without the "x". Also resuming playback must bring the service back to foreground.
(3): Currently this also happens when the notification is dismissed with the "x".