Can't stream local mp3 to Google Cast Audio

Hi there,

I’m having trouble playing mp3 files on my Chromecast Audio.
Streaming radio url works fine:

  radio538:
    alias: Play Radio538 on Chromecast Audio
    sequence:
      - alias: Start stream
        service: media_player.play_media
        data:
          entity_id: media_player.cc_audio
          media_content_id: http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3
          media_content_type: 'audio/mp4'    

However, I can’t manage to play mp3 files.

- alias: 'Rule 4 - Welcome John Doe'
  trigger:
    platform: state
    entity_id: device_tracker.johndoe
    state: 'home'
  action:   
    service: media_player.play_media
    data:
      entity_id: media_player.cc_audio
      media_content_id: '/local/test.mp3'
      media_content_type: 'audio/mp3'

mp3 file is stored in my www folder (in which my pictures are also stored that I use in known_devices.yaml).

media_content_id: '/home/homeassistant/.homeassistant/www/test.mp3'

Also doesn’t work.

I also tried putting the mp3 files in different directories (Music, MP3).

media_content_id: '/Music/test.mp3'

Chromecast is activated (I hear the activation sound) but nothing is played. Also there are no errors in my logfile.

Have you tried using a full URL instead of a relative reference?

What do you mean by “full URL”?

https://mydomain.myddns.org/www/mytunes.mp3

You’d have to create the www folder and give it appropriate read rights if it isn’t already there.

I allready created the www folder in my Home Assistant directory. That is also the directory where I store my contact pictures which I refer to in known_devices.yaml. Those pictures show up in my frontend. The path I use there is:

xxxxxxxxxx:
  hide_if_away: false
  mac: xx:xx:xx:xx:xx:xx
  name: John Doe
  picture: /local/test.jpg
  track: true
https://mydomain.myddns.org/www/mytunes.mp3

Same output (Chromecast is activated and “playing” but there is no sound).

How can I check the current permissions for the www folder?

Use ls -l

try
https://mydomain.myddns.org/local/mytunes.mp3

3 Likes

Thanks.

Folder permissions:

drwxrwxrwx+  2 root          root               4096 Jan 11 18:45 www

File permissions:

-rwxrwxrwx 1 root root  73301 Nov 18 21:37 test.mp3

It works! Thanks a lot :smiley:

Great!

you can also use

http://hass_local_ip:8123/local/your_file.mp3

I tried that earlier but that didn’t work. I assumed that would be because I have SSL enabled (?).

I guess so

Yes, because of SSL.

I’m sorry that I wasn’t clearer on my post; I thought that you would see it as an example and instead replace that with the actual folder you were using.

No need to apologize!

I replaced it with my own credentials, the "local’ instead of “www” did the trick

Well back to square one…
Suddenly stopped working after updating to 0.36 + installing the picotts library…

MP3 plays fine in my browser

same for me after updating to 0.36

Permissions look fine on the www folder (right?).

Can’t it be it has something to do with root user instead of home assistant user?

Traceback error

17-01-16 20:30:30 aiohttp.server: Error handling request
Traceback (most recent call last):
  File "/home/pi/.homeassistant/deps/aiohttp/web_server.py", line 61, in handle_request
    resp = yield from self._handler(request)
  File "/home/pi/.homeassistant/deps/aiohttp/web.py", line 249, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/http/static.py", line 62, in static_middleware_handler
    resp = yield from handler(request)
  File "/home/pi/.homeassistant/deps/aiohttp/web_urldispatcher.py", line 486, in _handle
    ret = yield from self._file_sender.send(request, filepath)
  File "/home/pi/.homeassistant/deps/aiohttp/file_sender.py", line 201, in send
    yield from self._sendfile(request, resp, f, count)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/http/static.py", line 30, in sendfile
    yield from orig_sendfile(request, resp, fobj, count)
  File "/home/pi/.homeassistant/deps/aiohttp/file_sender.py", line 108, in _sendfile_system
    yield from fut
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 269, in result
    raise CancelledError
concurrent.futures._base.CancelledError

more users reporting the same issue:
https://community.home-assistant.io/t/36-0-aiohttp-update-errors/9782