Internet Radio and More #2082
Replies: 2 comments 4 replies
-
You can use -- Discover speakers
local speakers = {}
for _, side in ipairs(peripheral.getNames()) do
if peripheral.getType(side) == "speaker" then
table.insert(speakers, peripheral.wrap(side))
end
end
local function startRadio(stationUrl)
stopRadio()
local w, err = http.websocket(convertUrl)
w.send(stationUrl)
if not w then return end
ws = w
running = true
parallel.waitForAny(playAudio, receiveAudio)
end You need just fix a bit of your parallel logics parallel.waitForAny(
function()
while running do
playAudio()
end
end,
... will immediately exits because parallel.waitForAny(
function()
while true do
if running then
playAudio()
else
sleep(0)
end
end
end,
... |
Beta Was this translation helpful? Give feedback.
-
Pro tip: you can use ngrok to run your own server without port forwarding, etc. Run server, run ngrok, point the server to the URL ngrok gives to you, (you must replace https:// to wss://) and it just works! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have made a CC:T program and accompanying service that makes use of WebSockets, yt-dlp and ffmpeg to enable streaming of Live Music into the game via ComputerCraft, from YouTube, Twitch, Internet Radio Sources, basically anywhere you can get an audio feed.
https://github.com/Krutonium/InternetRadio2Computercraft
Tell me what you think (and also if you know how to unstuck the GUI!)
(I'll leave my reference server open at ws://krutonium.ca:2468 for a while for your use - Please don't abuse this, and host your own if you're planning to use it long term)
Beta Was this translation helpful? Give feedback.
All reactions