Hi list,

I agree with Frederic: I don't see a simple way of doing all this
without merging the three ads before-hand. Note that this merging
could be done on the fly using a protocol and a little scripting (if
re-encoding is acceptable, it should be doable with liquidsoap only).

The not-simple way is to do a fair amount of scripting for the switch
logic. One way is to use source.dynamic(), the other one is to use
custom switching predicates. I'll detail the latter a little bit
because it seems like the best approach here. Please note that I
didn't have time to test this and never used this precise trick, so
there may be quirks.

First, create a function (call it next_source) which tells what should
be played. Assuming that it returns a string, successive calls to that
function should return:
 "song", "song", "jingle", "song", "song", "jingle", "ad", "ad", "ad",
"jingle", "song", "song", "jingle", "song"...
I'll let you take care of this one, you should use references to store
the state of your system.

Next, the following code will use that function to set flags saying
what should be played:

play_song = ref true
play_jingle = ref false
play_ad = ref false
def update_switch()
  next = next_source()
  if next == "song" then play_song := true end
  if next == "jingle" then play_jingle := true end
  if next == "ad" then play_ad := true end
end

Finally, set up a switch to use those flags, and update flags after each track:

source = on_track(fun(_)->update_switch(),switch([
  ({!play_song},song_source),
  ({!play_jingle},jingle_source),
  ({!play_ad},ad_source)
  # you may want to add a default, eg. ({true},song_source)
]))

>> Also, if possible, we would like to stop Liquidsoap from crossfading
>> between ads.

That's another story, but an easy one: use metadata. You should be
able to find some info about this on the list, or perhaps somewhere in
the doc.

Hope this helps,
-- 
David

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to