Android can't read iPhone recorded audio files -
i record audio file ios application , send android application through web server. android application gets file when use mediaplayer class try , play it, reports error "unable to create media player" @ line mediaplayer.setdatasource(androidfilepath);
mention, ios devices can read files sent app. after research found may encoding issue. tried many recording settings provided here on none has worked. here code use record audio file:
avaudiosession *audiosession = [avaudiosession sharedinstance]; [audiosession setcategory:avaudiosessioncategoryrecord error:nil]; nsmutabledictionary *recordsettings = [[nsmutabledictionary alloc] initwithcapacity:10]; [recordsettings nsnumber numberwithint: kaudioformatmpeg4aac] forkey: avformatidkey]; [recordsettings setobject:[nsnumber numberwithfloat:16000.0] forkey: avsampleratekey]; [recordsettings setobject:[nsnumber numberwithint:1] forkey:avnumberofchannelskey]; [recordsettings setobject:[nsnumber numberwithint: avaudioqualitymin] forkey: avencoderaudioqualitykey]; } nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *basepath = paths[0]; self.audiourl = [nsurl fileurlwithpath:[nsstring stringwithformat:@"%@/recordtest.caf", basepath]]; nserror *error = nil; self.audiorecorder = [[ avaudiorecorder alloc] initwithurl:self.audiourl settings:recordsettings error:&error]; if ([self.audiorecorder recordforduration:60] == yes){ [self.audiorecorder record]; }
could tell me change have make android devices can read audio files?
try removing avencoderaudioqualitykey code , check if solves problem. check if android device checking able play other aac files or not.
Comments
Post a Comment