Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop polling server for playlist. #246

Closed
vrtisworks opened this issue Aug 13, 2015 · 1 comment
Closed

Stop polling server for playlist. #246

vrtisworks opened this issue Aug 13, 2015 · 1 comment

Comments

@vrtisworks
Copy link

I am writing a script that will go ask a server for the next song to play.

It works fine, as long as the http server is up and running when I start up liquid soap. If the server is not up, or crashes, there doesn't seem to be a way to tell Liquidsoap to quit trying to load the playlist. I put a little timer on the back for testing, and even after I issue the source.shutdown, the log still shows that Liquidsoap is trying to ask the server for a file.

Can somebody tell me what I'm doing wrong? Or how I can start and stop Liquidsoap polling the server for the file?

I am running 1.0.1 on a Raspberry Pi if that makes a difference.

Thanks.

#!/usr/bin/liquidsoap
#
#Put the log file in some directory where
#you have permission to write.
#set("log.file.path","./liquidtesting.log")
set("log.file",false)
#Print log messages to the console,
set("log.stdout", true)
#Use the telnet server for requests while testing
set("server.telnet", true)

#We have a dummy/blank source/output to keep things running
blanksource = blank(id='blanksource')
output.dummy(fallible=false, blanksource);

#A few functions/stuff we need to control the player
#we need a boolean reference to set (true|false), initially false
player_on = ref false
thelist = ref playlist("")

def turn_player_on()
    #Only turn it on if it is currently off
    log("Turning player on")
    if !player_on == false then
        #set the flag it is on
        player_on := true
        #create the playlist and then output it to the speakers.
        pl=playlist(id="url_list", mode="normal", reload=1, reload_mode="rounds","http://localhost:3000/getNextSongFileName")
        thelist := pl
        #radio=fallback(id="the_radio",track_sensitive=false,
        #    [pl,blanksource])
        myout =  output.alsa(id='localAudio', device="hw: Set",pl)
    end
end

#A function to create 'thelist' playlist when we have node all up and ready
def turn_player_off()
    #Only turn it off if it is already on
    log ("Turning Player off")
    if !player_on == true then
        #set the flag it is off
        player_on := false
        #Shutdown the node source
        source.shutdown(!thelist)
        log (source.id(!thelist))
    else
        shutdown()
    end
    #add_timeout expects a function that will return a float
    0.5
end

turn_player_on()
add_timeout(0.5,turn_player_off)
@vrtisworks
Copy link
Author

Apparently the trick is that you have to shutdown BOTH the playlist AND the output. Then the playlist tries one more time and gives up.

@toots toots closed this as completed Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants