Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/astra
- source_path = "/mnt/playlist"
- package.path = "/etc/astra/scripts/?.lua"
- log.info("Starting Astra ")
- output_addr = "238.1.1.254"
- output_port = 1234
- playlist = {}
- for d in utils.readdir(source_path) do
- table.insert(playlist, d)
- end
- current_item = 0
- channel = {}
- channel.input = nil
- channel.transmit = transmit({})
- channel.output = udp_output({
- upstream = channel.transmit:stream(),
- addr = output_addr,
- port = output_port,
- })
- function play_item()
- current_item = current_item + 1
- if current_item > #playlist then
- -- log.info("End of playlist") -- Расскоментировать, если нужно проиграть содержимое папки 1 раз
- -- astra.exit() -- Расскоментировать, если нужно проиграть содержимое папки 1 раз
- log.info("Return to the begginning of playlist")
- current_item = 1
- end
- log.debug("Play: " .. playlist[current_item])
- channel.input = file_input({
- filename = source_path .. "/" .. playlist[current_item],
- callback = function()
- play_item()
- end
- })
- log.debug("Play full filename: " .. source_path .. "/" .. playlist[current_item])
- channel.transmit:set_upstream(channel.input:stream())
- end
- play_item()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement