Hi,

On Mon, Nov 10, 2008 at 12:38 AM, Matej Nastran <[EMAIL PROTECTED]> wrote:
> Let's say I want to add a fixed jingle after EVERY track of playlist. How do 
> I do that?

Let's start with that simple example.
src/liquidsoap scripts/utils.liq '
  s = single("/tmp/ecky.mp3")
  p = playlist("~/media/audio/jingle")
  p = append(p, fun (_) -> s)
  out(p)'

First I defined a jingle source, that repeatedly plays the same one.
Then I defined my normal source, a playlist. The normal source is
wrapped with append() using the following expression: append(p, fun(_)
-> s). Indeed, append is parametrized by a function, which will take
the track's metadata. Here we ignore the metadata since we always play
the same jingle: fun (_) -> s. (We could also have written fun (foo)
->s, but _ is used to indicate that we deliberately ignore.)

A more complex example of append is say_metadata() which is defined in
utils.liq (scripts/utils.liq in the source, installed in
/usr/lib/liquidsoap/VERSION):

# Append speech-synthesized tracks reading the metadata.
# @category Source / Track Processing
# @param ~pattern Pattern to use
# @param s The source to use
def say_metadata
  p = 'say:$(if $(artist),"It was $(artist)$(if $(title),\", $(title)\").")'
  fun (s,~pattern=p) ->
    append(s,fun (m) -> request.queue(queue=[request.create(pattern % m)],
                                      interactive=false))
end

You can see that append is parametrized by a function which, depending
on the track's metadata, builds the source to append. Here the
function is:
  fun (m) -> request.queue(queue=[request.create(pattern %
m)],interactive=false)
What it does is: replace the $(values) in the pattern by those of the
metadata, create a request (file) with the resulting URI, put it in a
queue. That queue is set to non-interactive to avoid cluttering the
server interface, so all it does is resolve the request, play it once,
and then fail: at this point the appending ends and a new track of the
original source (s) is played.

Note that right now, I don't see why we used that complex queue()
idea, and why single() would not suffice. I suspect that the spec of
append() changed over time and that this example could use a refresh.

Note also that append() won't do anything when no metadata is
available on a track. I think I'll make it invent an empty metadata
chunk instead, and make the old behavior optional.

Cheers,
-- 
David

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to