PDA

View Full Version : Autoplay on device discovery?



TurnipMan
2016-02-27, 03:44
Hello,
I've made myself a portable SB my combining a Chromecast Audio which I power with one of those high capacity phone charger batteries and a battery powered speaker. As the CC does consume power even when not being used it drains the battery over time so I plug it in as I need it. The Chromecast Bridge plugin http://forums.slimdevices.com/showthread.php?104614-Announce-CastBridge-integrate-Chromecast-players-with-LMS-(squeeze2cast) (Thanks Philippe) only takes about 30 secs to discover it.
Is there any way to make the player start a particular stream when the device is available?
Tom

DJanGo
2016-02-27, 04:14
Hi,

i did (mostly) the same but my player "starts" the stream instead of the lms Server after discovering.
or better: the player told the server to start the stream.

I took this way because its less overhead for the server.

its a simple if then bash script that uses the lms cli over netcat.

TurnipMan
2016-02-27, 06:09
Hi,

i did (mostly) the same but my player "starts" the stream instead of the lms Server after discovering.
or better: the player told the server to start the stream.

I took this way because its less overhead for the server.

its a simple if then bash script that uses the lms cli over netcat.

Sounds good. Any chance of some detailed illumination? Pretty please!
Tom

DJanGo
2016-02-27, 08:00
Sounds good. Any chance of some detailed illumination? Pretty please!
Tom

I didnt know, if my solution is working for you, cause its written for a rasberry pi.

Please take a look at the cli commands in the help section of your lms Server.

You can use something like:


player count ?
or

player connected ?

I am not sure how and what the subscribe feature does, may thats a better starting point for you.

DJanGo
2016-02-27, 08:28
Is there any way to make the player start a particular stream when the device is available?
Tom

btw after some thinking ...

if its always the same stream you may can simple use the audiosettings from this player (located under settings)...

Power On Resume
and set that to:

Stop at Power Off/ Restart playlist at Power on

TurnipMan
2016-02-27, 10:59
btw after some thinking ...

if its always the same stream you may can simple use the audiosettings from this player (located under settings)...
and set that to:

Brilliant I'll have a go at that.

TurnipMan
2016-02-27, 11:08
Brilliant I'll have a go at that.

That didn't work. I suppose with the SB Classic etc when you "Power Off" with a remote they don't really go off in thae same way as cutting the power on the ChromeCast Audio.
Time to try the CLI stuff, never looked at that before.

Tom

DJanGo
2016-02-27, 12:28
That didn't work. I suppose with the SB Classic etc when you "Power Off" with a remote they don't really go off in thae same way as cutting the power on the ChromeCast Audio.
Time to try the CLI stuff, never looked at that before.

Tom
whats the os that poweres your lms ?

TurnipMan
2016-02-27, 12:36
It's on a Rpi2 with Max2Play so it's linux.

DJanGo
2016-02-27, 13:46
It's on a Rpi2 with Max2Play so it's linux.

:o
than you should start with something like that (unless another user has a better idea..)


check if max2play has netcat installed eg writing nc [return] in your shell
get the macadress from the Chromcast device
add these lines to a file and name that "autoplay.sh"


#! /bin/sh

###vars:
## change that to the mac adress from the Chromcast Device
playerID="50:40:30:20:10"

#the stream/playlist
my_playlist="/playlist_path/playlist.m3u"

server=127.0.0.1
port=9090

connected=$(printf "$playerID connected ?\nexit\n" |nc $server $port|cut -d ' ' -f 3)
if [ ! $connected = 1 ]
then
exit 1
fi

playerstatus=$(printf "$playerID power ?\nexit\n" |nc $server $port|cut -d ' ' -f 3)
if [ ! $playerstatus = 1 ]
then
echo "powering player on"
printf "$playerID power 1\nexit\n"|nc $server $port
else
echo "player is on"
fi

playermode=$(printf "$playerID mode ?\nexit\n" |nc $server $port|cut -d ' ' -f 3)
if [ ! $playermode = play ]
then
echo "nothing to play"
echo "try to play players playlist"
printf "$playerID play\nexit\n"|nc $server $port
sleep 2
playermode=$(printf "$playerID mode ?\nexit\n"|nc $server $port|cut -d ' ' -f 3)
if [ ! $playermode = play ]
then
echo "no playlist loaded we play $my_playlist now"
printf "$playerID playlist play $my_playlist\nexit\n"|nc $server $port
fi
else
echo "playing"
fi

exit 0

place that file somewhere under /opt or /usr/local/bin and make it executeable by chmod +x /path/filename

use sudo crontab -e
and add something like:

*/15 * * * * /path/filename.sh
to start that script each 15 mins.

I know its kind off ugly and not perfect cause it runs all 15 minutes and i dont know whats happen, when the device is powered on but paused cause you want to make a phonecall and so on.

So it "NOT" really what you looking for it doesnt handle a "device connected and just powered on" - it just a device is connected and it should play my playlist/stream.

TurnipMan
2016-02-27, 13:54
Thanks. I'll try it in the morning.

philippe_44
2016-02-27, 14:31
That didn't work. I suppose with the SB Classic etc when you "Power Off" with a remote they don't really go off in thae same way as cutting the power on the ChromeCast Audio.
Time to try the CLI stuff, never looked at that before.

Tom

I've added a while ago a 'hidden' (not available in the GUI) function that autoplays what's "pending" in LMS for that player when it is turned on/discovered. You have to set the <auto_play> parameter to 1 in the castbridge.xml config file. It sends a "play" command to LMS through the CLI interface

TurnipMan
2016-02-27, 15:14
I've added a while ago a 'hidden' (not available in the GUI) function that autoplays what's "pending" in LMS for that player when it is turned on/discovered. You have to set the <auto_play> parameter to 1 in the castbridge.xml config file. It sends a "play" command to LMS through the CLI interface

Fantastic. I'll give that a go.

TurnipMan
2016-02-28, 01:12
Philippe,
I won't surprise you to find out that your tip works. Thanks.
Is there any chance you could surface that option in a the GUI in a future version. Plus the ability to specifically select an item from ones favorites as the default "play" stream - in case the kids have been playing something I'm not so keen on first thing in the morning.
Tom