Le samedi 1 janvier 2011 13:18:39, Henry Favretto a écrit :
> Hi all,
Hi !
> I use the following code (liquidsoap 0.9.3) for generating timed promotions
> in certain random intervals:
>
> interval = random.float(min=2800.0,max=5000.0)
> timed_promotions = delay(interval, promotions)
> radio = smooth_add(p=0.4, special=timed_promotions, normal=radio)
>
> , where "promotions" and "radio" are both playlist sources.
>
> Everything works nice except for one thing: When I start the channel the
> special content ("timed_promotions") always gets played first - which is
> not preferred. Rather, my intention is to have the output starting with
> the normal content ("radio") and the special content to be played back for
> the first time only after the first interval has passed.
>
> Any idea how I can achieve that?
I think i can solve two things here :)
First, I am not sure if this is intentional but "interval" in your script is
*static*. It is a random float initialized when starting the script but it will
not change later on..
I believe that perhaps you intented this value to change between two
promotions... In this case, the delay operator is not interesting (it does not
support interactive floats -- maybe a todo!). However, you may be able to do it
using add_timeout.
add_timeout registers a task to be executed after a given timeout. When
executed, the task returns a new float. If this float is positive or null, the
tasks will be executed again after the given amount of time.
In you case, you may create a task that inserts new promotions. For instance:
8<----------------------->8
promotions = request.queue()
def add_promotion() =
# Get a new promotion
# Replace this code with what you
# want..
promotion = list.hd(get_process_lines("find ~/promotions | \
sort -R | \
head -n 1"))
# Push it in the queue
ignore(server.execute("#{source.id(promotions)}.push #{promotion}"))
# Return a random float
random.float(min=2800.0,max=5000.0)
end
# Register task
initial_timeout = random.float(min=2800.0,max=5000.0)
add_timeout(fast=false, initial_timeout, add_promotion)
8<----------------------->8
This also solves your second problem because the task is registered with an
initial random timeout.
Romain
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users