Sonos audio/mp4 error?

I’m trying to stream a radio station to my Sonos Play:3 speaker. Here is the relevant code that causes an error:

    onStationSelect(e) {
        this.hass.callService('media_player', 'play_media', {
            entity_id: this._selectedSpeaker,
            media_content_id: e.currentTarget.stationUrl,
            media_content_type: 'audio/mp4'
        });
    }

The stream I’m playing is: https://nwmedia-kgbi.streamguys1.com/kgbi-mp3

This results in the following error in my logs when I try to stream:

2021-01-04 10:40:51 ERROR (SyncWorker_10) [homeassistant.components.sonos.media_player] Sonos does not support a media type of "audio/mp4"

I changed the 'audio/mp4' to 'music' and music, but all three result in the same error shown above. I restarted HA in between to ensure the js file was using the new version. Anything else I can try to stream radio to a Sonos Play:3?

Did you try with a local file? The error you posted also appears when the file can’t be played from HA.
Are your SSL certificates valid?

I tested also the same and came to the end:

media_content_type: ‘music’
Stream URL must end wit *.mp3

then it works

I’m not sure I understand. Are you saying adding “.mp3” to the end of your stream url made it work for you on a Sonos? Because when I add “.mp3” to my url, the stream no longer works at all.

I didn’t try local files because Sonos can already play those. I’m not using SSL with HA, so I’m not sure how that comes into play with this issue. Thanks for your reply.

Try this: https://zt.cdn.eurozet.pl/zet-tun.mp3

Same error:

2021-01-04 14:27:27 ERROR (SyncWorker_2) [homeassistant.components.sonos.media_player] Sonos does not support a media type of "audio/mp4"

If that stream plays on your Sonos and not mine, it makes me think I have an error somewhere else in my configuration.

I see now that your example URL doesn’t point to a file. I didn’t read that it is a radio station. I think you need to add it to Sonos and then you can choose it as a source in Home Assistant. That’s what I read in the forum.
Also try media_content_type: 'channel' might be worth a try as well.

1 Like