Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Plymouth, UK
    Posts
    100

    Autoplay on device discovery?

    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/showth...(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

  2. #2
    Senior Member
    Join Date
    Sep 2005
    Posts
    2,848
    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.
    Last edited by DJanGo; 2016-02-27 at 04:16.

  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Plymouth, UK
    Posts
    100
    Quote Originally Posted by DJanGo View Post
    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

  4. #4
    Senior Member
    Join Date
    Sep 2005
    Posts
    2,848
    Quote Originally Posted by TurnipMan View Post
    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:

    Code:
    player count ?
    or
    Code:
    player connected ?
    I am not sure how and what the subscribe feature does, may thats a better starting point for you.

  5. #5
    Senior Member
    Join Date
    Sep 2005
    Posts
    2,848
    Quote Originally Posted by TurnipMan View Post
    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

  6. #6
    Senior Member
    Join Date
    Jan 2007
    Location
    Plymouth, UK
    Posts
    100
    Quote Originally Posted by DJanGo View Post
    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.

  7. #7
    Senior Member
    Join Date
    Jan 2007
    Location
    Plymouth, UK
    Posts
    100
    Quote Originally Posted by TurnipMan View Post
    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

  8. #8
    Senior Member
    Join Date
    Sep 2005
    Posts
    2,848
    Quote Originally Posted by TurnipMan View Post
    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 ?

  9. #9
    Senior Member
    Join Date
    Jan 2007
    Location
    Plymouth, UK
    Posts
    100
    It's on a Rpi2 with Max2Play so it's linux.

  10. #10
    Senior Member
    Join Date
    Sep 2005
    Posts
    2,848
    Quote Originally Posted by TurnipMan View Post
    It's on a Rpi2 with Max2Play so it's linux.

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

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

    Code:
    #! /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:
    Code:
    */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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •