Le Tuesday 16 December 2008 18:42:50 Brandon Casci, vous avez écrit :
> When the playlist is
> over, the dj process just hits the API URL which gets a new playlist
> populated by my rotation logic. Can I do something similar with liquidoap?

Surely, yes !

I guess it should be done using a request.dynamic source.

This source uses a custom function of yours to feed its queue. The function is 
called whenever you have less then a default amount of time available for 
playing (by default a minute or something like that) and should return the 
URI of the next song to play.

The difficulty in your case is that you want to proceed using playlists. The 
easier solution would be that you can call a webservice that only returns the 
next song to play, not a full playlist.

However, if you really want to implement it using a playlist, then you can. If 
you look at the code in utils.liq [1], you will find the code of the 
playlist.once operator, which basically does the same, but does not reload 
the playlist when it is finished.

If you want to be able to reload the playlist, you have to use string.ref, 
which is at the moment the only way to define persistent values in liquidsoap 
(this is a classic issue with functional programming).

I won't comment the code in details now (you can ask later of course), but 
basically, you should have the following (not tested but I am confident):
  # Define a reference to a string:
  x = string.ref("")
  # x is a pair of functions (get,set)
  # Let extract the functions:
  get = fst(x)
  set = snd(x)  

  # Define setter and getter:
  def get_playlist() = 
    s = get()
    string.split(seperator="$",s)
  end

  def set_playlist(l) = 
    # l is a list of strings representing URIs.
    # You can use any other string than "$" as 
    # the separator, provided it does not occur in the
    # URIs.
    s = string.concat(separator="$",l) 
    set(s)
  end

Then, the rest of the code can be copied from playlist.once. When you have 
reached the end of the playlist, you should get a new playlist, set to the 
new value, reinitialize the position counter to 0 and return a new URI from 
this new playlist :)


Hope I have been clear..

Romain

[1]: http://savonet.rastageeks.org/browser/trunk/liquidsoap/scripts/utils.liq


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to