willyb321

RS_Mixer_upd.lua

May 15th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. --[[
  2.  RS Mixer for VLC >= 1.0
  3.  Authors: Willyb321 (https://tehsuperwilly.tech)
  4. --]]
  5.  
  6. stations = {
  7.     { name = "Radio Sidewinder", url = "http://radiosidewinder.out.airtime.pro:8000/radiosidewinder_a", id = "RS",},
  8. }
  9. function descriptor()
  10.     return { title = "RS Mixer" ;
  11.              description = "Mix your own music with Radio Sidewinder! Make sure to add songs to your library in VLC." ;
  12.              version = "1.0" ;
  13.              author = "Willyb321" ;
  14.              url = "https://tehsuperwilly.tech" ;
  15.              capabilities = {} }
  16. end
  17.  
  18. function activate()
  19.     dlg = vlc.dialog("Streaming Radio Player")
  20.     list = dlg:add_list(1, 3, 4, 1)
  21.     button_play = dlg:add_button("Play", click_play, 1, 2, 2, 1)
  22.     button_skip = dlg:add_button("Mix!", mixUp, 3, 2, 2, 1)
  23.     button_add = dlg:add_button("Add Library", addLibrary, 5, 2, 2, 1)
  24.     button_radio = dlg:add_button("RS", rsListen, 7, 2, 2, 1)
  25.     -- Add RS
  26.     for idx, details in ipairs(stations) do
  27.         list:add_value(details.name, idx)
  28.     end
  29.     dlg:show()
  30. end
  31.  
  32. function click_play()
  33.     selection = list:get_selection()
  34.     if (not selection) then return 1 end
  35.     local sel = nil
  36.     for idx, selectedItem in pairs(selection) do
  37.         sel = idx
  38.         break
  39.     end
  40.     details = stations[sel]
  41.  
  42.     -- Play the radio station
  43.     playlistItem = {}
  44. playlistItem.path = details.url
  45. vlc.playlist.clear()
  46. vlc.playlist.add( {playlistItem} )
  47. vlc.playlist.play()
  48. end
  49. -- play random song from list
  50. function mixUp()
  51. local rnd = math.random(5)
  52. math.randomseed(os.time())
  53. vlc.playlist.skip(rnd)
  54.  
  55. end
  56. -- skip back to radio station
  57. function rsListen()
  58. vlc.playlist.goto(1)   
  59. end
  60. -- import library from VLC into playlist
  61. function addLibrary()
  62. mediaAdd = vlc.playlist.get("media library")
  63. vlc.playlist.add( {mediaAdd} )
  64. end
  65.  
  66. function deactivate()
  67. end
  68.  
  69. function close()
  70.     vlc.deactivate()
  71. end
Advertisement
Add Comment
Please, Sign In to add comment