skorokithakis / catt

Cast All The Things allows you to send videos from many, many online sources to your Chromecast.
BSD 2-Clause "Simplified" License
3.34k stars 153 forks source link

Cast Local File in ChromeOS Crostini Linux VM: Not Working #439

Open darethehair opened 9 months ago

darethehair commented 9 months ago

So close yet so far! I have been trying to find a CLI utility to cast media, and so far 'catt' has the best chance of working, but not quite yet:

Playing an MP3 stored on my website from within the Crostini VM shell works great:

darren@penguin:~$ sudo /root/.local/bin/catt cast http://mywebsite/test.mp3
Casting remote file http://mywebsite/test.mp3...
Playing "test" on "Downstairs Speaker"...

Playing a copy of the same MP3 as a local file hangs for a little while, then fails:

darren@penguin:~$ sudo /root/.local/bin/catt cast test.mp3
Casting local file test.mp3...
Playing "test" on "Downstairs Speaker"...
Serving local file(s).
Error: Playback of local file has failed.

If I can make this work, then I will be able to set up some crontab schedules to play media at my local non-profit thrift shop at designated times -- with the benefit of being able to 'cast' it from a central PC.

darethehair commented 8 months ago

More tests and results...

I eventually figured out how to use 'pychromecast' myself to cast an audio file to a Chromecast speaker 'by name', just like 'catt' can, even working in a ChromeOS Crostini environment using the simple 'http-server' webserver, and it works fine:

dmenns@penguin:~$ /home/dmenns/castaudio.py "Downstairs Speaker" http://192.168.5.45:8080/test.mp3
argument list ['/home/dmenns/castaudio.py', 'Downstairs Speaker', 'http://192.168.5.45:8080/test.mp3']
Downstairs Speaker

When I try the same thing with 'catt' using similar instructions, it hangs and eventually fails:

dmenns@penguin:~$ catt -d "Downstairs Speaker" cast http://192.168.5.45:8080/test.mp3
ERROR: [generic] Unable to download webpage: (<urllib3.connection.HTTPConnection object at 0x7d3289e91e10>, 'Connection to 192.168.5.45 timed out. (connect timeout=20.0)') (caused by TransportError("(<urllib3.connection.HTTPConnection object at 0x7d3289e91e10>, 'Connection to 192.168.5.45 timed out. (connect timeout=20.0)')"))
Error: Remote resource not found.

Even though I have found this workaround, I would still like to be able to use 'catt' as my sole utility in this environment, since it appears to work well for casting 'web pages' which I also want/need to do.

skorokithakis commented 8 months ago

Hmm, is Catt maybe detecting and sending the wrong IP for its host?

darethehair commented 8 months ago

Another successful test of an alternate app 'chromecast-cli' (https://github.com/erkstruwe/chromecast-cli):

dmenns@penguin:~$ chromecast --host 192.168.4.35 play http://192.168.5.45:8080/test.mp3
Playing http://192.168.5.45:8080/test.mp3
Status IDLE

This works OK, but I prefer the ability of Catt to target the host on its name rather than its (possibly changing over time) IP address.

Is there something I can do to help diagnose what might be going off-track with Catt in this case?

skorokithakis commented 8 months ago

Hm, you'd need to find which host CATT has detected for itself and is sending to the Chromecast, but I'm afraid I don't remember the code enough to remember where that variable is set... I think the problem is that it's detecting the wrong host, though.