ios - Audio file doesn't play in iPhone 5 -


i use code playing .caf audio file, same code works in iphone 4s , ipad 2 doesn't play @ in iphone 5...

this code:

-(ibaction)checksound:(id)sender  {     nsurl *url = [nsurl fileurlwithpath:[nsstring stringwithformat:@"%@/lunatic.caf", [[nsbundle mainbundle] resourcepath]]];   nslog(@"%@",url);  nserror *error;  self.audioplayer = [[avaudioplayer alloc] initwithcontentsofurl:url error:&error];  self.audioplayer.numberofloops = 0;   self.audioplayer.volume = 1;    nslog(@"log audioplayer: %@",audioplayer);  if (audioplayer != nil) {     [self.audioplayer preparetoplay];     [self.audioplayer play]; }   if (audioplayer.playing == no) {     nslog(@"not playing, error: %@",error); }   if([[nsfilemanager defaultmanager] fileexistsatpath:@"file://localhost/var/mobile/applications/0d3f5169-8db1-4398-a09a-db2fbadf57ef/myapp.app/lunatic.caf"]) {     nslog(@"file exist"); } else {     nslog(@"file doesn't exist"); }    } 

and log output:

2013-08-07 20:05:52.694 myapp[7006:907] file://localhost/var/mobile/applications/0d3f5169-8db1-4398-a09a-db2fbadf57ef/myapp.app/lunatic.caf 2013-08-07 20:05:52.697 myapp[7006:907] log audioplayer: (null) 2013-08-07 20:05:52.701 myapp[7006:907] not playing, error: error domain=nsosstatuserrordomain code=-43 "the operation couldn’t completed. (osstatus error -43.)" 2013-08-07 20:05:52.703 myapp[7006:907] file doesn't exist

as can see audioplayer log gives "null" , error log says error -43.... repeat... iphone 4s works good....

any clue why happening? did change audio in iphone 5? setting in iphone 5 that's preventing sound play? appreciated

have called [audioplayer preparetoplay] prior calling play? have double checked audioroutes ensure playing out of proper channel?

two sanity checks to:

1.) call [audioplayer isplaying] , see if returns yes or no after call play.

2.) set avaudioplayerdelegate , wait callback on audioplayerdidfinishplaying: , see if gets called after length of audio.

http://developer.apple.com/library/ios/#documentation/avfoundation/reference/avaudioplayerclassreference/reference/reference.html

edit: since you're file isn't playing, means have wrong path you're calling.

print out path nslog , check see if file exists using:

if([[nsfilemanager defaultmanager] fileexistsatpath:yourpath]) {  } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -