2013-08-04 2 views
2

Хорошо, я puling моих волос в течение нескольких часовLiquidsoap не определение переменного четко определен

Liquidsoap просто не работает для меня, и я знаю, что это должно работать, суб для одной appearently очевидной ошибки ...

set("log.file",false) 
set("log.stdout",true) 
set("log.level",3) 

podcasts = playlist("/home/user/icecast/ham.txt") 

# This function turns a fallible 
# source into an infallible source 
# by playing a static single when 
# the original song is not available 
def my_safe(radio) = 
    # We assume that festival is installed and 
    # functional in liquidsoap 
    security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!") 
    # We return a fallback where the original 
    # source has priority over the security 
    # single. We set track_sensitive to false 
    # to return immediately to the original source 
    # when it becomes available again. 
    fallback(track_sensitive=false,[radio, security]) 
end 

radio= podcasts 
radio= my_safe(podcasts) 

# A function that contains all the output 
# we want to create with the final stream 
def outputs(s) = 
    # First, we partially apply output.icecast 
    # with common parameters. The resulting function 
    # is stored in a new definition of output.icecast, 
    # but this could be my_icecast or anything. 
    output.icecast = output.icecast(host="localhost", password="foobar") 
    # An output in mp3 to the "live" mountpoint: 
    output.icecast(%mp3, mount="live",radio) 
end 

И ошибка

At line 23, character 6: The variable radio defined here is not used anywhere 
    in its scope. Use ignore(...) instead of radio = ... if you meant 
    to not use it. Otherwise, this may be a typo or a sign that your script 
    does not do what you intend. 

Если кто-то мог бы также исправить еще один вопрос у меня

Я хотел бы найти, как запустить два источника на два отдельных точек монтирования

set("log.file",false) 
set("log.stdout",true) 
set("log.level",3) 

podcasts = playlist("/home/user/icecast/ham.txt") 
songlist = playlist("/home/user/icecast/otherplaylist.txt") 

# This function turns a fallible 
# source into an infallible source 
# by playing a static single when 
# the original song is not available 
def my_safe(radio) = 
    # We assume that festival is installed and 
    # functional in liquidsoap 
    security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!") 
    # We return a fallback where the original 
    # source has priority over the security 
    # single. We set track_sensitive to false 
    # to return immediately to the original source 
    # when it becomes available again. 
    fallback(track_sensitive=false,[radio, security]) 
end 

radio= podcasts 
radio= my_safe(podcasts) 

def my_safe(songlist) = 
    # We assume that festival is installed and 
    # functional in liquidsoap 
    security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!") 
    # We return a fallback where the original 
    # source has priority over the security 
    # single. We set track_sensitive to false 
    # to return immediately to the original source 
    # when it becomes available again. 
    fallback(track_sensitive=false,[songlist, security]) 
end 

moarradio= songlist 
moarradio= my_safe(songlist) 

# A function that contains all the output 
# we want to create with the final stream 
def outputs(s) = 
    # First, we partially apply output.icecast 
    # with common parameters. The resulting function 
    # is stored in a new definition of output.icecast, 
    # but this could be my_icecast or anything. 
    output.icecast = output.icecast(host="localhost", password="foobar") 
    # An output in mp3 to the "live" mountpoint: 
    output.icecast(%mp3, mount="live",radio) 

    output.icecast(%mp3, mount="otherlive",moarmusic) 
end 

И я получаю ту же ошибку, но он говорит мне, что вторая переменная не используется (moarradio)

ответ

1

liquidsoap файл конфигурации в основном является скриптом, что означает, что он будет выполняться сверху вниз.

При чтении файла конфигурации, он жалуется, что вы не используете radio переменной, определенной в строке 23, по причине того, вы используете одну определенную линию 24. В отличие от многих других языков, есть no assignations, only definitions в Liquidsoap сценарии

Помимо этого вы, похоже, не понимаете разницы между глобальными и локальными переменными и их соответствующими областями.

Вы объявляете функцию my_safe, которая принимает аргумент. В рамках функции обратитесь к своему аргументу с его именем. Затем вызовите функцию my_safe с вашими глобальными переменными в качестве аргумента, и то, что вы ожидаете, на самом деле произойдет.

Ваши источники не будут зарегистрированы, если вы не вызываете функцию outputs. Просто отбросьте конструкцию функции.

Вот как я переписал свой второй пример:

set("log.file",false) 
set("log.stdout",true) 
set("log.level",3) 

podcasts = playlist("/home/user/icecast/ham.txt") 
songlist = playlist("/home/user/icecast/otherplaylist.txt") 

# This function turns a fallible 
# source into an infallible source 
# by playing a static single when 
# the original song is not available 
def my_safe(stream) =       # <- used a different variable name here 
    # We assume that festival is installed and 
    # functional in liquidsoap 
    security = single("say:Hello, we are currently having some technical difficulties but we'll be back soon so stay tuned!") 
    # We return a fallback where the original 
    # source has priority over the security 
    # single. We set track_sensitive to false 
    # to return immediately to the original source 
    # when it becomes available again. 
    fallback(track_sensitive=false,[stream, security]) # <- used a different variable name here 
end 

radio= my_safe(podcasts) # <- fix here 

# <- got rid of redeclaration of my_safe 

moarradio= my_safe(songlist) # <- fix here 

# <- got rid of function construct 
# First, we partially apply output.icecast 
# with common parameters. The resulting function 
# is stored in a new definition of output.icecast, 
# but this could be my_icecast or anything. 
output.icecast = output.icecast(host="localhost", password="foobar") 
# An output in mp3 to the "live" mountpoint: 
output.icecast(%mp3, mount="live",radio) 
output.icecast(%mp3, mount="otherlive",moarradio) # <- fix here 
Смежные вопросы