I am putting together a trial for a client and we need to play audio. This seems fine on some files but not on others, the only difference I can see is the size of file. I am trying both .caf & .mp3. In both instances, 1 of the 4 audio files plays (the smallest).
Is there a limit to audio files, and what is the best format (size is not an issue at the moment as it’s a canned demo but in the long run it very much will be as the audio will be loaded from a server, but that’s another set of problems 
Files sizes are -
4684PageText - 1.5mb (.caf), 401kb (.mp3)
4987PageText - 2.1mb (.caf), 582kb (.mp3)
5290PageText - 188kb (.caf), 53kb (.mp3) (this is the one that plays)
5593PageText - 2.1mb (.caf), 578kb (.mp3)
Cheers [import]uid: 4523 topic_id: 608 reply_id: 300608[/import]
Which call are you using?
There is media.newEventSound which is for “caf” for 1 to 3 seconds (cafs)
and
media.playSound for longer than 3 seconds ( mp3 )
Take a look at the APIReference guide page 40.
Carlos [import]uid: 24 topic_id: 608 reply_id: 1178[/import]
That’ll be it 
I was using media.newEventSound, using media.playSound seems to do the trick.
Cheers Carlos, you are a star 
Gary [import]uid: 4523 topic_id: 608 reply_id: 1180[/import]
A follow up on this one.
I am downloading the audio file from a sever and putting it onto the phone then playing it. This is not working and crashes the app (simulator & on iPhone). I know Apple don’t really want people to download & play audio without going through iTunes but I need to do this so any ideas?
AudioFolder and AudioFileName are global variables holding the url of the path & the filename (this code works for downloading text & image files, and it does download the audio, just doesn’t play it)
I may be addressing the wrong thing …
function loadAudio()
local testtext1=display.newText(“Downloading Audio”,0,35,nil,12)
testtext1:setTextColor( 255,0,0 )
local urlString = AudioFolder … AudioFileName
local path = system.pathForFile( AudioFileName, system.DocumentsDirectory )
local myFile = io.open( path, “w+” )
http.request{
url = urlString,
sink = ltn12.sink.file(myFile),
}
media.playSound( path )
os.remove( path )
end
Cheers
Gary [import]uid: 4523 topic_id: 608 reply_id: 1268[/import]
what does “path” return?
send me code at support@anscamobile.com and i can take a look.
C [import]uid: 24 topic_id: 608 reply_id: 1274[/import]
Email sent
Cheers
Gary [import]uid: 4523 topic_id: 608 reply_id: 1285[/import]