Le Wednesday 13 May 2009 13:33:55 Kero, vous avez écrit :
> Hello,

        Hi !

> Writing here as suggested on IRC.
>
> Here is the deal :
>
> I'm running a webradio with a music playlist most of the day, and some
> live shows usually during the evening. These show can last from 1 to
> more than 7 hours, it all depends on the mood of the DJ.
> All live shows are saved by liquidsoap in different files using
> output.file.mp3
>
> Now, I would like to be able to rerun my shows during nights and
> afternoons. It has to stop and go back to the main playlist once the show
> has been entirely rebroadcasted. And also at special hours, even if the
> rebroadcast is still running.
>
> So I was thinking of something like :
>
> pre_rerun = playlist.once("path/rerun.m3u")
> music = playlist("path/music.m3u")
> true_rerun = fallback([pre_rerun, music])
> switch([ ({10h00-16h00}, music),({16h00-20h30},
> true_rerun),({20h30-3h00}, music),({3h00-10h00}, true_rerun)] )
>
> The main problem is : playlist_once has no way of reloading rerun.m3u
> - so it would play the same playlist everyday even tho the files are
> changing.

It is even worse: playlist.once will not be available any more when it has 
finished, so that you shall need to restart liquidsoap..

> I've heard there was a workaround for this, a way to force a playlist
> to run only once per switch while being regularly reloaded. I would be
> interested by such a solution. :-)

For this case, I have another idea in mind. You should be able to perform 
something relatively simple using a queue of request and a recursive task.

Something like:

rerun = request.queue(id="rerun")

Now the trick is to register a recursive task for adding the new live shows. 
Roughly, something like:

def add_live() = 
  # We check if it is time to push a request
  if 16h00-20h30 or 3h00-10h00 then
    # We check if we are already running a live
      ret = list.hd(server.execute("rerun.queue"))
      if ret == "" then
        # We get the file/uri to play (can be a obtained from a script or 
        # anything else)
        file = (...)
        # We push the request
        ignore(server.execute("rerun.push #{file}"))
      end
  end
  # We run again in one minute
  60.
end

Eventually, we register the task:
add_timeout(60., add_live)

The purpose of this recursive task is to feed the rerun source. It will feed 
it if it is the correct time for broadcasting the live archive, and only if 
another archive is not already being played.

When an archive ends, within at most one minute, if it is still time, it will 
start another live.

We could also check the duration of the file, using file.duration, and if there 
is not enough time for it, don't push it, but I am nto sure there is a 
function for that in the language for now..

Eventually, we can add the switch that will make sure we play the archive at 
the correct time:

# This transition skips the current track when switching..
def transition(a,b) =
  source.skip(a)
  # This eats the last remaining frame from a
  sequence([a,b])
end

full = switch(track_sensitive=false, transitions=[transition,transition], 
                   [({16h00-20h30 or 3h00-10h00}, rerun), ({true}, music) ])

We set track_sensitive to false to make sure that the switch can occur in the 
middle of an archive. We could set it to true if we check for available time 
before starting a live, as explained above.

The transition function is also needed when track_sensitive is false. It makes 
sure that if switching back to music in a middle of an archive, then this 
track is skiped, such that the next time we play an archive, it starts with a 
fresh one.


I did not test the code above, but I think it should mostly be correct. Let me 
know if you need more details.. I may also add something inspired by that in 
the standard library.


Romain

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to