54 lines
1.6 KiB
Markdown
54 lines
1.6 KiB
Markdown
# Correctif étape 11 — état lecture + seek du Player de fond
|
|
|
|
Les nouveaux logs montraient deux problèmes précis :
|
|
|
|
```text
|
|
lifecycle=hidden ... playing=true
|
|
lifecycle=paused ... playing=true
|
|
AudioTrack ... stop
|
|
screen interactive=false ... playing=false
|
|
start dedicated audio ... recentlyPlaying=false
|
|
switching ... shouldPlay=false
|
|
dedicated player ready at 0 ms playing=false
|
|
```
|
|
|
|
Donc :
|
|
|
|
1. Android arrête le Player vidéo AVANT `ACTION_SCREEN_OFF`.
|
|
2. Notre code perdait l'information qu'il était en lecture.
|
|
3. Le Player audio de fond recevait `shouldPlay=false`.
|
|
4. Son `seek` à ~111 s était envoyé trop tôt et restait à 0 s.
|
|
|
|
## Correctif
|
|
|
|
### Intention de lecture
|
|
|
|
Au callback lifecycle `inactive/hidden/paused`, tant que le Player vaut encore
|
|
`playing=true`, on mémorise `continueOnLock=true`.
|
|
|
|
Quand `ACTION_SCREEN_OFF` arrive plus tard, cette valeur est utilisée même si
|
|
Android a déjà mis le Player vidéo à `playing=false`.
|
|
|
|
### Seek du Player audio
|
|
|
|
Le Player de fond attend désormais que la durée du média soit connue, puis :
|
|
|
|
1. seek à la position courante ;
|
|
2. vérification de la position ;
|
|
3. jusqu'à 3 tentatives ;
|
|
4. seulement ensuite `play()` ;
|
|
5. confirmation que `playing=true`.
|
|
|
|
## Logs attendus
|
|
|
|
```text
|
|
[BACKGROUND] lifecycle=AppLifecycleState.hidden ... continueOnLock=true
|
|
[BACKGROUND] native screen interactive=false ... playing=false
|
|
[BACKGROUND] start dedicated audio ... continueOnLock=true
|
|
[BACKGROUND-AUDIO] switching ... shouldPlay=true
|
|
[BACKGROUND-AUDIO] seek attempt 1 -> ...
|
|
[BACKGROUND-AUDIO] seek confirmed ...
|
|
[BACKGROUND-AUDIO] dedicated player ready at ... playing=true
|
|
[BACKGROUND] dedicated audio active
|
|
```
|