If, by console log, you mean the output to the terminal window, everything looks fine when I run it on the simulator as either an iPhone or Droid. It’s not until I build it and load it on my Android that it fails to work. If there is another log where I can look, please let me know. In the meanwhile, I will search for it.
On another note, I tried adding razvan’s recommended fix, changing the content-type to mpeg, which I believe is the appropriate type for mp3. Again, it works on the simulator fine but not on my Android.
BTW: I changed the code as shown below. In the simulator, AND on the android phone, I can now verify the file is received and it’s the correct size. Really, the only thing missing appears to be the actual audio, so maybe the problem is with the audio.load or audio.play portions. I did verify the volume is up on the phone.
local selSound
local socket = require “socket”
local function testNetworkConnection()
local netConn = socket.connect(‘www.google.com’, 80)
if netConn == nil then
return false
end
netConn:close()
return true
end
local myText = display.newText(" ", 160, 20, native.systemFont, 16)
myText:setTextColor(255, 255, 255)
local function networkListener( event )
if ( event.isError ) then
myText.text = myText.text … " but Download Failed"
else
local lfs = require “lfs”
local file_path = system.pathForFile( “1acv01_fra_01a.mp3”, system.DocumentsDirectory )
local size = lfs.attributes (file_path, “size”)
myText.text = myText.text … " Size:" … size
selSound = audio.loadSound(“1acv01_fra_01a.mp3”,system.DocumentsDirectory)
audio.play(selSound)
end
print ( "RESPONSE: " … event.response )
end
if testNetworkConnection then
local params = {}
local headers = {}
local theURL = “http://www.gotfuturama.com/Multimedia/MP3Sounds/1acv01_fra_01a.mp3”
headers[“Content-Type”] = “audio/mpeg”
headers[“Accept-Encoding”] = “identity”
params.headers = headers
myText.text = "Online "
network.download(theURL, “GET”, networkListener, params, “1acv01_fra_01a.mp3”,system.DocumentsDirectory)
else
myText.text = “No Network”;
end [import]uid: 196941 topic_id: 33801 reply_id: 140950[/import]