# This function is called when # a new metadata block is passed in # the stream. def apply_metadata(m) = title = m["title"] artist = m["artist"] print("Now playing: #{title} by #{artist}") end # функция для воспроизведения рекламы во время проигрывания музыки def smooth_add(~delay=0.75,~p=0.,~normal,~special) d = delay fade.final = fade.final(duration=d*1.) fade.initial = fade.initial(duration=d*4.) q = 1. - p c = amplify fallback(track_sensitive=false, [special,normal], transitions=[ fun(normal,special)-> add(normalize=false, [c(p,normal), c(q,fade.final(type="lin",normal)), sequence([blank(duration=d),c(q,special)])]), fun(special,normal)-> add(normalize=false, [c(p,normal), c(q,fade.initial(type="lin",normal))]) ]) end
#!/usr/bin/liquidsoap set("init.daemon.pidfile.path","/home/sa/radio/pids/bravo_20.pid") set("init.daemon",true) set("log.file.path","/home/sa/radio/logs/bravo_20.log") set("tag.encodings", ["UTF-8"]) set("log.level",3) %include "library.liq" def get_request() = uri = list.hd(get_process_lines("/home/sa/radio/php/bravo_20.php")) request.create(uri) end s = request.dynamic(id="s",get_request) s = on_metadata(apply_metadata,s) rek = single("/opt/mp3/reklama/bravo_20_00.mp3") s = smooth_add(normal=s,special=switch([({ 0m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_05.mp3") s = smooth_add(normal=s,special=switch([({ 5m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_10.mp3") s = smooth_add(normal=s,special=switch([({ 10m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_15.mp3") s = smooth_add(normal=s,special=switch([({ 15m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_20.mp3") s = smooth_add(normal=s,special=switch([({ 20m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_25.mp3") s = smooth_add(normal=s,special=switch([({ 25m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_30.mp3") s = smooth_add(normal=s,special=switch([({ 30m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_35.mp3") s = smooth_add(normal=s,special=switch([({ 35m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_40.mp3") s = smooth_add(normal=s,special=switch([({ 40m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_45.mp3") s = smooth_add(normal=s,special=switch([({ 45m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_50.mp3") s = smooth_add(normal=s,special=switch([({ 50m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_55.mp3") s = smooth_add(normal=s,special=switch([({ 55m0s },rek)])) # We output the stream to an icecast # server, in ogg/vorbis format. output.icecast(%mp3(id3v2=true,bitrate=128),id="icecast", fallible=true,mount="bravo_20", name="какое-то имя", description="_", host="localhost", password="********", s)
rek = single("/opt/mp3/reklama/bravo_20_35.mp3") s = smooth_add(normal=s,special=switch([({ 35m0s },rek)]))
... ]rek = single("/opt/mp3/reklama/bravo_20_00.mp3") s = smooth_add(normal=s,special=switch([({ 0m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_05.mp3") s = smooth_add(normal=s,special=switch([({ 5m0s },rek)])) rek = single("/opt/mp3/reklama/bravo_20_10.mp3") s = smooth_add(normal=s,special=switch([({ 10m0s },rek)])) ...
... def get_request_reklama() = uri = list.hd(get_process_lines("/home/sa/radio/php/bravo_20_rek.php")) request.create(uri) end rek = request.dynamic(id="s",get_request_reklama) s = smooth_add(normal=s,special=switch([({ 0m0s or 5m0s or 10m0s or 15m0s },rek)])) ...
#!/usr/bin/php -q <?php $d = date( 'i', mktime() ); echo "/opt/mp3/reklama/bravo_20_" . $d . ".mp3"; ?>