ios - Objective-C - Trying to play sound -
i trying play sound in app following code:
nsstring *soundfilepath = [[nsbundle mainbundle] pathforresource:@"errorbeep.wav" oftype:@"m4a"]; nsurl *soundfileurl = [nsurl fileurlwithpath:soundfilepath]; avaudioplayer *player = [[avaudioplayer alloc] initwithcontentsofurl:soundfileurl error:nil]; player.numberofloops = -1; //infinite [player play];
but sound not play :(
after debugging, can see soundfilepath nil here screenshot of resources file:
you should import file project 1 extension. thats what's going on. re-import file 1 extension (i.e, errorbeep.m4a)
Comments
Post a Comment