I've gotten all the way to getting the callback to execute, but it seems that minetest.sound_play() isn't actually playing the data from response.data
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
if http then
http.fetch({url = "hpr.dogphilosophy.net/test/ogg.ogg", timeout = 30},
function(res)
minetest.log("error", "JUKEBOX: HTTPRequest called back!")
local meta = minetest.env:get_meta(pos)
for k, v in pairs(res) do
minetest.log("error", k .. " = " .. tostring(v))
end
meta:set_string("hwnd", minetest.sound_play(res.data, {gain = 0.5, max_hear_distance = 25}))
minetest.log("error", "JUKEBOX: Sound played?")
end)
end
And this is the output I get from that at runtime:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
2016-10-18 00:04:52: ACTION[Server]: Mod performs HTTP request with URL hpr.dogphilosophy.net/test/ogg.ogg
2016-10-18 00:04:57: ERROR[Server]: JUKEBOX: HTTPRequest called back!
2016-10-18 00:04:57: ERROR[Server]: succeeded = true
2016-10-18 00:04:57: ERROR[Server]: code = 200
2016-10-18 00:04:57: ERROR[Server]: completed = true
2016-10-18 00:04:57: ERROR[Server]: timeout = false
2016-10-18 00:04:57: ERROR[Server]: data = OggS
2016-10-18 00:04:57: ERROR[Server]: JUKEBOX: Sound played?
I've confirmed that using a local file instead of res.data works fine.
Am I missing something?
Edit: I tired writing res.data to a file and ended up with a file containing "OggS." I guess the API doesn't let me work with binary data.
Edit 2: Yeah, looks like the engine just pushes a string over to the API. https://github.com/minetest/minetest/bl ... tp.cpp#L86