I run Lubuntu 14.04.3 LTS and I have downloaded and installed castnow to stream videos from my PC to my Chromecast.
The only alternative I know is to do this via Videostream using Chromium. But that uses so many more resources that my poor old laptop barely cannot take it...
I find that castnow works really well. But it is a command line tool and to start it I have to go to a terminal window and run:
castnow --address [ip address chromecast] --myip [localip] [path to video]
This works, but I would find it much easier if I could navigate to the video using my file manager (pcmanfm
) and open the video.
I have tried to create a script file that runs the above command using the selected file as an input parameter (%f) but I have failed misserably...
And my dear friend Google has not been able to help me so far. Can anyone help me to get this done?
Update 16 Oct:
I have nearly done it!
The thing that took most time was to find the bug in pcmanfm that it does not execute shell scripts. The following article describes this well and gives a workaround: https://bugs.launchpad.net/ubuntu/+source/lubuntu-default-settings/+bug/975152
I have created a .desktop file that executes a script and passes the file as a parameter. This appears as an option in the menu and that way you can also select it in pcmanfm.
The script takes the filename as a parameter and runs castnow with all the parameters. Unfortunately it doesn't work.
The script I created goes like this:
filename=$1
filename=${filename:7:$((${#filename}-7))}
filename=${filename//%20/\\ }
echo castnow --address 192.168.0.21 --myip 192.168.0.47 $filename
castnow --address 192.168.0.21 --myip 192.168.0.47 $filename
The result is:
castnow --address 192.168.0.21 --myip 192.168.0.47 /home/joost/Videos/American\ Horror\ Story\ Season\ 1\ Complete\ 480p\ BZINGAZ/american.horror.story.s01e11.720p.hdtv.x264-compulsion.mkv
Error: Load failed
And when I copy the command to another terminal window it works. How can this be? And how can it be solved.
Another update:
The problem seems to be related to the spaces in the path. The desktop file sends the path to the bash script with the %u parameter. And as the folder has some spaces in it, they are converted to %20 In the script I convert these back to "\ ". If I test my stuff with a file that has no spaces it works (!!!).
But spaces are part of life. How to get around this?
And another update:
I did it! With a bit of tricking, but it works. I have added some lines in the script to replace all spaces by underscores on the file system:
#!/bin/bash
# replace all spaces by underscores in the Videos-folders and -files:
find /home/joost/Videos/ -name "* *" -type d | rename 's/ /_/g' # do the directories first
find /home/joost/Videos/ -name "* *" -type f | rename 's/ /_/g'
filename=$1
# remove file:// from the file-variable:
filename=${filename:7:$((${#filename}-7))}
# new films may contain spaces in the path. They have been replace by underscores. This also needs to happen in the parameter:
filename=${filename//%20/_}
# now we are ready to go:
castnow --address 192.168.0.21 --myip 192.168.0.47 $filename
read
It works and I am happy with it. But if someone knows how to get around the spaces I'd be happy to know.
Update 18 Oct:
I have found out how to get around the spaces (and other special characters). First of all I found out how to urldecode the paramater. But the trick to get around the spaces (and other special characters) turns out to be to add 'eval' to the statement. So the final statement in my script is now: eval castnow --address 192.168.0.21 --myip 192.168.0.47 $filename
So, that's it. Only remaining issue is that castnow doesn't seem to be able to play avi files. I have created an issue for this at github.