I've tried AVAudioPlayer and now SoundEffect (from Apple sample code) and both work fine in simulator but not on my iPhone (software version 4.2.1).
Any ideas why?
And tell me if there's a better site to ask this question.
EDIT: I also asked on http://www.iphonedevsdk.com/ and https://discussions..../thread/3258943.
[iPhone] AVAudioPlayer and SoundEffect only work in simulator
I started a new OpenGL ES project and added AVFoundation framework and
and
and added /sounds/ to the project, but it still doesn't work on my iPhone.
Here is the project:
http://corpstates.my...ads/testApp.zip
SOLVED: my phone ring switch was set to mute.
#import <AVFoundation/AVAudioPlayer.h>
#import <AudioToolbox/AudioServices.h>
and
- (void) viewDidLoad
{
NSString* soundFilePath = [[NSBundle mainBundle] pathForResource: @"csva" ofType: @"caf"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
NSError *error = nil;
AVAudioPlayer* sound = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: &error];
if(error)
NSLog(@"error: %@ (%@)", error, error.userInfo);
else
NSLog(@"no error");
sound.delegate = self;
sound.volume = 1.0f;
[sound prepareToPlay];
[fileURL release];
[sound play];
}
and added /sounds/ to the project, but it still doesn't work on my iPhone.
Here is the project:
http://corpstates.my...ads/testApp.zip
SOLVED: my phone ring switch was set to mute.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement