Okay i could pass a function as the switch predicate, the only problem is
that the function was evaluated only on the first round.The code is
something like this for now:
------------------------------------------------------------------------------------------------------------
count=0
def checkTime(interval)
    count=count+1
    if count>=2 then
        {true}
    else
        {false}
    end
end
src=switch(track_sensitive=true,[(checkTime(11h06m),zero),({true},default)])
------------------------------------------------------------------------------------------------
The final code  would be something like:
-----------------------------------------------------------------------------------------------------------------------
mutable alreadyPlayed={}#A dictionary or something to hold ids  as keys with
boolean value
def checkTime(interval,id){
  if(alreadyPlayed[id]==true) then
    {false}
  else
    if(interval<=now)#Probably will need to create a function that compare
predicate with current time for LS to use
    alreadyPlayed[id]=true
    {true}
  end
 end
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Probably i would have to change the behaviour of the switch to reevaluate
every item after each round also.

Em 19 de outubro de 2011 10:54, Fábio Costa <[email protected]>escreveu:

> It's kind like that but the interval would be large enough .
> Let's say i putted a source that lasts for 2 hours at 8h , and i put a
> jingle to play at 9h. After the end of this two hour source at 10 o'clock
> the jingle would be played and move off the list.
> Will see the functions you said, a liquidsoap only aproach would be more
> interesting than hacking the code.
>
> Em 19 de outubro de 2011 10:40, David Baelde 
> <[email protected]>escreveu:
>
> OK I see,
>>
>> 2011/10/19 Fábio Costa <[email protected]>:
>> >
>> src=switch(track_sensitive=true,single=[true,false],[({08h44},jingle),({true},default)])
>>
>> This does not play the jingle often enough.
>>
>> >
>> src=switch(track_sensitive=true,single=[true,false],[({08h44-9h44},delay(3600,,jingle)),({true},default)])
>>
>> This is a solution, but making the time predicate larger forces you to
>> add a delay, and the choice of one hour seems ad-hoc, there might not
>> be a sensible default in all cases.
>>
>> Would this be a good specification of what you're trying to do: given
>> a time interval (in your example, 8h44 to 8h45) be ready to play the
>> source during the interval, but only once?
>>
>> If so, it should be possible to do this as a script, writing a
>> function interval_once which takes something like {8h44} and a source,
>> and returns a pair (F,source) to be used in a switch list, where F is
>> a predicate that reads a flag (reference on a boolean): first it reads
>> the interval (obtaining in_interval), and unsets the flag if we're
>> outside the interval; then if the flag is not set it returns
>> in_interval, if the flag is set it returns false. In addition, wrap
>> the source in a on_track that sets the flag when a track starts
>> playing, and you should be close to done.
>>
>> Tell me what you think,
>>
>> David
>>
>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to