Le mardi 17 août 2010 11:42:22, rafael a écrit :
> Hi Romain and everyone,

        Hi !

> Thanks for answering so quickly. I am sure the active community and
> helpful developers liquidsoap has will be very imporant to spread it. I
> hope to contribute with some frontend for plone cms...

Thanks ! I have seen your other message, however I need to look for the 
previous frontend before answering it..

> I am still getting used to liquid scripts.. 

Thanks for your patience :)

> I tried the code you
> sent,but it is still not what I want. I want to add a single track only
> once in the begining of the playlist (which is randomized). The append
> function, appends this track to every track.

I see.

Then, you probably only need a sequence and a request.queue with a single 
file, or a single with once. For instance:

q = request.queue(interactive=false, 
queue=[request.create("/path/to/jingle.mp3"])
s = sequence([q,playlist])

This should play one song from q and then switch to the playlist.

> I also did not get some of the syntax of the code:
> 
> a) Why I need a function to create the single mp3 source? why
> single(path) is not enough?

This is because, by default, a single() source loops on its track. You can 
create a source that plays a single track with a request.queue with a single 
track in the queue, as explained above, or use:
  s = once(single("/path/to/file.mp3"))
I do not know which one is the best, though..

> b) The function add_track(_) has no return statement, so how can I know
> what it returns?  (_) means no arguments? Is this ocaml syntax?

It is functional syntax, which can be confusing when you aren not used to it.
There is no return statement in functional language, the returned value is
implicitely the last value in the code, which was the created source in the 
code I gave you.

When I wrote:
def f(_) = 
(...)
end

I meant that f receives an argument but does not use it.

> c) When I changed the order of arguments in the call to "s =
> append(add_track, s)" I got an error.

Yes, arguments without labels cannot be swaped, i.e. f(x,y) is not
the same as f(y,x). However, arguments with labels can, i.e.
f(foo=x,bar=y) = f(bar=y, foo=x)

> What is the difference between objects of type source and of type
> [(string*string)])->source('a) ? Is the second object metadata?

This is another functional specificity. Argument of type:
[(string*string)])->source('a) are functions that take a list of 
(string*string) and return a source. 

The list of string*string is the metadata of the track, i.e. something
of the form: [("title","foo"), ("artist", "bar"), ...]

The function would then look at the metadata and return the source 
to append.

> Anyway, i see that the right way to do what I want is to script in
> python, the language I am most familiar with, this will be no problem. I
> just have a single question about this:
> 
> I saw a post of someone saying he runs the python script before running
> liquidsoap and then statically pass the playlist. But I don't wan't to
> do that. I would like liquidsoap to call the python scripts..

Liquidsoap can call any external script. You may do two things:
 * Call a script when liquidsoap starts and use its output for creating the 
source,
i.e. something like:
  list = get_process_lines("/path/to/script")
  reqs = list.map(request.create,list)
  s = request.queue(queue=reqs)
 * Setup a source using request.dynamic which would call the script each time 
it needs 
to queue a new songs (normally about 5 sec before the end of the current song).

However, you may be able to do what you want more easily using the trick 
explained
at the beginning of this email !


Romain

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to