audio - iOS8 & xcode6 no longer plays sound -



audio - iOS8 & xcode6 no longer plays sound -

i'm having problem appeared after big update ios 8 , xcode6.

when seek play sound audiotoolbox nil comes out speakers. using simulator.

i have 2 variants of function plays sound.

-(void)playsound:(nsstring *)filename { systemsoundid soundeffet = [self soundeffect]; nsurl *soundurl = [[nsbundle mainbundle] urlforresource:filename withextension:@"mp3"]; nsstring *urlstring = [soundurl absolutestring]; if ([[nsfilemanager defaultmanager] fileexistsatpath:urlstring]) { audioservicescreatesystemsoundid((__bridge cfurlref)soundurl, &soundeffet); audioservicesplaysystemsound(soundeffet); } else { nslog(@"error, file not found: %@", filename); } }

this fails file exists @ path check.

-(void)playsound:(nsstring *)filename { systemsoundid soundeffet = [self soundeffect]; nsstring *path = [[nsbundle mainbundle] pathforresource:filename oftype:@"mp3"]; if ([[nsfilemanager defaultmanager] fileexistsatpath:urlstring]) { nsurl *pathurl = [nsurl fileurlwithpath:path]; audioservicescreatesystemsoundid((__bridge cfurlref)pathurl, &soundeffet); audioservicesplaysystemsound(soundeffet); } else { nslog(@"error, file not found: %@", filename); } }

this 1 doesn't play anything.

i sure file name using correct.

does have ideas changed these no longer work? , important: how prepare this?

so figured out! (cue flailing kermit arms.) reinhard manner's comment pointed me in right direction. did indeed end using avaudioplayer. here's ended with.

-(void)playsound:(nsstring *)filename { nsstring *soundfilepath = [[nsbundle mainbundle] pathforresource:filename oftype: @"mp3"]; nsurl *fileurl = [[nsurl alloc] initfileurlwithpath:soundfilepath]; soundplayer =[[avaudioplayer alloc] initwithcontentsofurl:fileurl error:nil]; if (soundplayer != nil) { [soundplayer play]; } else { nslog(@"could not play file %@", filename); } }

not included here soundplayer synthesized @ top of file , made a property in .h file.

i still don't know why audiotoolbox stopped working. works, , i'm going it.

also, reinhard manner, may want post type of thing reply next time, can more credit!

audio ios8 xcode6 audiotoolbox

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -