Advertisement
JDVU

Untitled

Oct 12th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #!/usr/bin/astra
  2.  
  3. source_path = "/mnt/playlist"
  4.  
  5. package.path = "/etc/astra/scripts/?.lua"
  6.  
  7. log.info("Starting Astra ")
  8.  
  9. output_addr = "238.1.1.254"
  10. output_port = 1234
  11.  
  12. playlist = {}
  13.  
  14. for d in utils.readdir(source_path) do
  15. table.insert(playlist, d)
  16. end
  17.  
  18. current_item = 0
  19.  
  20. channel = {}
  21. channel.input = nil
  22. channel.transmit = transmit({})
  23. channel.output = udp_output({
  24. upstream = channel.transmit:stream(),
  25. addr = output_addr,
  26. port = output_port,
  27. })
  28.  
  29. function play_item()
  30. current_item = current_item + 1
  31. if current_item > #playlist then
  32. -- log.info("End of playlist") -- Расскоментировать, если нужно проиграть содержимое папки 1 раз
  33. -- astra.exit() -- Расскоментировать, если нужно проиграть содержимое папки 1 раз
  34. log.info("Return to the begginning of playlist")
  35. current_item = 1
  36. end
  37.  
  38. log.debug("Play: " .. playlist[current_item])
  39.  
  40. channel.input = file_input({
  41. filename = source_path .. "/" .. playlist[current_item],
  42. callback = function()
  43. play_item()
  44. end
  45. })
  46.  
  47. log.debug("Play full filename: " .. source_path .. "/" .. playlist[current_item])
  48.  
  49. channel.transmit:set_upstream(channel.input:stream())
  50.  
  51. end
  52.  
  53. play_item()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement