@@ -14,27 +14,31 @@ local function parse_range(s)
14
14
end
15
15
16
16
local function http_result(self, _id, response, extra)
17
- if response.status == 200 or response.status == 206 then
17
+ if response.status == 200 or response.status == 206 or response.status == 304 then
18
18
--pprint(response.headers)
19
- -- pprint(response)
19
+ pprint(response)
20
20
print("Playing web sound:", response.url)
21
21
local relative_path = self.filename
22
- local range = response.headers['content-range'] -- content-range = "bytes 0-16383/103277"
23
- local rstart, rend, filesize = parse_range(range)
22
+ -- local range = response.headers['content-range'] -- content-range = "bytes 0-16383/103277"
23
+ -- local rstart, rend, filesize = parse_range(range)
24
24
-- Create the Defold resource, "partial" will enable the streaming mode
25
25
print("Creating resource", relative_path)
26
- local hash = resource.create_sound_data(relative_path, { data = response.response, filesize = filesize , partial = true })
26
+ local hash = resource.create_sound_data(relative_path, { data = response.response, filesize = response.document_size , partial = true })
27
27
-- send "play_sound" to the component
28
28
play_sound(self, hash)
29
29
end
30
30
end
31
31
32
32
local function load_web_sound(base_url, relative_path)
33
33
local url = base_url .. "/" .. relative_path
34
+
35
+ local range_start = 0
36
+ local range_end = 16384-1
34
37
local headers = {}
35
- headers['Range'] = string.format("bytes=%d-%d", 0, 16384-1 )
38
+ headers['Range'] = string.format("bytes=%d-%d", range_start, range_end )
36
39
37
- http.request(url, "GET", http_result, headers, nil, { ignore_cache = true })
40
+ local request = http.request(url, "GET", http_result, headers, nil)
41
+ print("REQUEST ID", request, "url:", url)
38
42
end
39
43
40
44
-- ***************************************************************************
@@ -50,6 +54,8 @@ function on_message(self, message_id, message)
50
54
if message_id == hash("start") then
51
55
self.source = message.source
52
56
self.sound_type = message.sound_type
57
+ print("MAWE: self.source", self.source)
58
+ print("MAWE: self.sound_type", self.sound_type)
53
59
if message.source == "Web" then
54
60
self.url = message.url
55
61
self.filename = message.filename
0 commit comments