Media player does not play URL

Media player does not play URL
local files play well

esphome:
  name: bedroom-speaker
  friendly_name: bedroom-speaker

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 10.0.1.110
    gateway: 10.0.1.1
    subnet: 255.255.255.0  

 ap:
    ssid: "bedroom-speaker"

captive_portal:

web_server:
  port: 80
  version: 2
  include_internal: true
  ota: false

i2s_audio:
  - id: i2s_in
    i2s_lrclk_pin: GPIO26 #WS 
    i2s_bclk_pin: GPIO25 #SCK

mqtt:
  broker: 10.0.1.111
  username: mqtt
  password: mqttt

media_player:
  - platform: i2s_audio
    name: "esp_speaker"
    id: media_player_speaker
    i2s_audio_id: i2s_in
    dac_type: external
    i2s_dout_pin: GPIO27   #  DIN Pin of the MAX98357A Audio Amplifier
    mode: mono

button:
  - platform: template
    name: Play Morrow
    id: play_morrow_radio
    entity_category: config
    on_press:
      - media_player.play_media:
          media_url: 'http://stream.fr.morow.com:8080/morow_med.mp3'
21:30:02	[D]	[media_player:066]	
  Media URL: http://stream.fr.morow.com:8080/morow_med.mp3
21:30:03	[W]	[component:214]	
Component i2s_audio.media_player took a long time for an operation (0.52 s).
21:30:03	[W]	[component:214]	
Component i2s_audio.media_player took a long time for an operation (0.52 s).
21:30:03	[W]	[component:215]	
Components should block for at most 20-30ms.
21:30:03	[W]	[component:214]	
Component i2s_audio.media_player took a long time for an operation (0.48 s).
21:30:03	[W]	[component:215]	
Components should block for at most 20-30ms.
21:30:03	[W]	[component:215]	
Components should block for at most 20-30ms.

The ESP speaker does not play all types of media. I noticed that my homemade esp speaker reboots if I try to play a high bitrate radio station stream or AAC format. The same goes for local files. Some of them play fine, some of them don’t play or cause the speaker to freeze/reboot.

I’ve found the same issue, posted @ Atom Lite media player only playing one file and also opened an issue @ Atom media player only playing one file · Issue #176 · esphome/firmware · GitHub

From the looks of the logging (verbose), it’s actually trying to open and decode the AAC files, but is constantly erroring on each byte(?). If the file is small enough then it eventually gets to the end, but file’s over a certain size, or is a stream, it eventually crashes/hangs the device.

From what I’ve seen, “normal” MP3 files and streams are OK, AAC is not.

I understand if these ESP32s can’t decode AAC or high-bitrate files/streams, but it would be nice if it failed cleanly and it was documented somewhere :slight_smile:

Alternatively, if there is an ESP board which can handle MP3 & AAC, and can output audio, then I’ll happily take a look at that (want to avoid the RasPi + DAC route if I can)