updated speaker driver
This commit is contained in:
@@ -8,9 +8,23 @@ local function getFileName(name)
|
|||||||
return fullFile
|
return fullFile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getSoundUrl(fileName)
|
||||||
|
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
|
||||||
|
local name = getFileName(fileName)
|
||||||
|
local fullPath = baseRoute .. name
|
||||||
|
return fullPath
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getSoundStream(fileName)
|
||||||
|
local request = http.get(getSoundUrl(fileName))
|
||||||
|
print(textutils.serialize(request.getResponseHeaders()))
|
||||||
|
request.close()
|
||||||
|
end
|
||||||
|
|
||||||
local function playSound(speaker, fileName)
|
local function playSound(speaker, fileName)
|
||||||
for input in io.lines(getFileName(fileName), 16 * 1024) do
|
local values = io.lines(getSoundStream(fileName), 16 * 1024)
|
||||||
local decoded = decoder(input)
|
for input in values do
|
||||||
|
local decoded = decoder(input)
|
||||||
while not speaker.playAudio(decoded) do
|
while not speaker.playAudio(decoded) do
|
||||||
os.pullEvent("speaker_audio_empty")
|
os.pullEvent("speaker_audio_empty")
|
||||||
end
|
end
|
||||||
@@ -27,6 +41,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function addSoundFile(fileName)
|
function addSoundFile(fileName)
|
||||||
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
|
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
|
||||||
local name = getFileName(fileName)
|
local name = getFileName(fileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user