fix(playback): 播放中不再向系统上报 idle,修复播放设备页显示未在播放

audio_service 把 idle 映射成 PlaybackState.STATE_NONE,之前用 duration>0 判断,
时长尚未解析出来时会一直上报 NONE。改为 playing || duration>0 即视为 ready。

设备验证(MEIZU 21 Pro / Android 16):
  播放 -> state=PLAYING(3),暂停 -> state=PAUSED(2),不再出现 NONE(0)。

同时加固 device-check.ps1:确认进程真正退出后再抓冷启动日志,最多重试两次。
This commit is contained in:
2026-10-22 22:57:34 +08:00
parent 6f9fe6262d
commit 6445ee94bf
2 changed files with 24 additions and 11 deletions
+5 -1
View File
@@ -116,9 +116,13 @@ class AudioPlayerHandler extends audio_service.BaseAudioHandler {
try {
final controls = _buildControls(playing);
// audio_service 侧映射:idle -> STATE_NONE,ready -> PLAYING/PAUSED。
// 之前只按 duration>0 判断,直播流/时长未解析出来时会被系统判定为"未在播放"
// (播放设备选择页、部分车机与耳机都会读到这个状态)。
final prepared = playing || duration.inMilliseconds > 0;
final state = audio_service.PlaybackState(
controls: controls,
processingState: duration.inMilliseconds > 0
processingState: prepared
? audio_service.AudioProcessingState.ready
: audio_service.AudioProcessingState.idle,
playing: playing,