Skip to content

Commit bac5acb

Browse files
n-IA-haneclaude
andcommitted
Media player: pause→stop, display fix, remove dead is_paused checks
on_pause converts to immediate media_player.stop (PAUSED holds 8KB internal RAM + HTTP connection + ring buffer — useless limbo state). Xiaozhi on_play shows neutral mood image (clears old VA text first). Remove all media_player.is_paused conditions (state is now transient). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 17194cf commit bac5acb

2 files changed

Lines changed: 25 additions & 38 deletions

File tree

waveshare-s3-audio-va-intercom-media-test.yaml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ media_player:
311311
on_play:
312312
- script.execute: restore_led
313313
on_pause:
314-
- script.execute: restore_led
314+
# PAUSED holds 5KB+3KB internal RAM (read_task+decode_task) + HTTP connection.
315+
# Stop immediately to free resources — HA can re-send URL if needed.
316+
- media_player.stop:
315317
on_idle:
316318
- script.execute: restore_led
317319
# Restart MWW after media finishes (but NOT during intercom calls)
@@ -516,12 +518,6 @@ intercom_api:
516518
id: media_speaker_mix
517519
decibel_reduction: 0
518520
duration: 500ms
519-
# Free PAUSED media pipeline resources (20KB internal read_task stack)
520-
- if:
521-
condition:
522-
media_player.is_paused:
523-
then:
524-
- media_player.stop:
525521
- script.execute: restore_led
526522
- if:
527523
condition:
@@ -540,12 +536,6 @@ intercom_api:
540536
id: media_speaker_mix
541537
decibel_reduction: 0
542538
duration: 500ms
543-
# Free PAUSED media pipeline resources (20KB internal read_task stack)
544-
- if:
545-
condition:
546-
media_player.is_paused:
547-
then:
548-
- media_player.stop:
549539
- script.execute: restore_led
550540
- if:
551541
condition:
@@ -564,12 +554,6 @@ intercom_api:
564554
id: media_speaker_mix
565555
decibel_reduction: 0
566556
duration: 500ms
567-
# Free PAUSED media pipeline resources (20KB internal read_task stack)
568-
- if:
569-
condition:
570-
media_player.is_paused:
571-
then:
572-
- media_player.stop:
573557
- light.turn_on:
574558
id: status_led
575559
red: 100%

xiaozhi-ball-v3-local-test.yaml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,29 @@ media_player:
427427
- script.execute: draw_display
428428
on_play:
429429
- script.execute: backlight_timer
430+
# Show neutral mood image during media playback (like old announcement behavior)
431+
- if:
432+
condition:
433+
and:
434+
- intercom_api.is_idle: intercom
435+
- not:
436+
voice_assistant.is_running:
437+
then:
438+
- lambda: |-
439+
// Clear old VA text, show neutral mood image
440+
id(wrapped_lines_reply).clear();
441+
id(reply_total_pages) = 1;
442+
id(reply_page_index) = 0;
443+
lv_img_set_src(id(mood_bg), id(mood_neutral));
444+
- script.execute: update_replying_text
445+
- globals.set:
446+
id: voice_assistant_phase
447+
value: '${voice_assist_replying_phase_id}'
448+
- script.execute: draw_display
430449
on_pause:
431-
- script.execute: backlight_timer
450+
# PAUSED holds 5KB+3KB internal RAM (read_task+decode_task) + HTTP connection.
451+
# Stop immediately to free resources — HA can re-send URL if needed.
452+
- media_player.stop:
432453
on_idle:
433454
- script.execute: backlight_timer
434455
# Restart MWW after media finishes (but NOT during intercom calls)
@@ -821,12 +842,6 @@ intercom_api:
821842
id: media_speaker_mix
822843
decibel_reduction: 0
823844
duration: 500ms
824-
# Free PAUSED media pipeline resources (20KB internal read_task stack)
825-
- if:
826-
condition:
827-
media_player.is_paused:
828-
then:
829-
- media_player.stop:
830845
- light.turn_off: led
831846
- lambda: 'id(peer_name) = id(intercom).get_current_destination();'
832847
- if:
@@ -858,12 +873,6 @@ intercom_api:
858873
id: media_speaker_mix
859874
decibel_reduction: 0
860875
duration: 500ms
861-
# Free PAUSED media pipeline resources (20KB internal read_task stack)
862-
- if:
863-
condition:
864-
media_player.is_paused:
865-
then:
866-
- media_player.stop:
867876
- if:
868877
condition:
869878
switch.is_off: mute
@@ -884,12 +893,6 @@ intercom_api:
884893
id: media_speaker_mix
885894
decibel_reduction: 0
886895
duration: 500ms
887-
# Free PAUSED media pipeline resources (20KB internal read_task stack)
888-
- if:
889-
condition:
890-
media_player.is_paused:
891-
then:
892-
- media_player.stop:
893896
- if:
894897
condition:
895898
switch.is_off: mute

0 commit comments

Comments
 (0)