Hi,

Your approach does not work because the source created in the `jingleover` 
command is not attached to the streaming tree. Here's one way that should work:

```
#!/usr/bin/liquidsoap

set("init.daemon.pidfile.path", "/var/run/liquidsoap/radio.liq.pid")
set("log.file.path", "/home/liquidsoap/log/liquidsoap.log")
set("log.level", 5)

set("server.telnet", true)
set("server.telnet.bind_addr", "0.0.0.0") # because of docker
set("server.timeout", -1.)

songs = audio_to_stereo(playlist(mode="normal", "~/content/music.m3u"))
jingles = audio_to_stereo(playlist("~/content/jingles"))

play_jingle = ref false

def on_jingle(_) =
  play_jingle := false
end

# Play a jingle when `play_jingle` is set to `true`
jingles = switch([({!play_jingle}, jingles)])

# Play one jingle at a time by setting `play_jingle` to 
# `false` immediately after one starts playing (`switch`
# above is `track_sensitive` so track will keep playing until
# it ends.
jingles = on_track(on_jingle, jingles)

songs = skip_blank(songs)
songs = crossfade(songs)

radio = random(weights=[1, 5], [jingles, songs])

security = single("/mnt/music/fallback.flac")

s = fallback(track_sensitive=false, [radio, security])
s = smooth_add(normal=s, special=jingles)

def jingleover()
   log("jingleover precalled")
   play_jingle := true
   log("jingleover postcalled")
end

def add_randomjingle_command(~command)
        server.register(
                usage="randomjingle",
                description="Play random jingle over stream",
                command,
                fun(_) -> begin jingleover() "Done!" end
        )
 end

add_randomjingle_command(command="randomjingle")

output.dummy(s)
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/savonet/liquidsoap/issues/768#issuecomment-493796362
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to