Sign in to follow this  
polyfrag

[iPhone] AVAudioPlayer and SoundEffect only work in simulator

Recommended Posts

polyfrag    2502
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 [url="http://www.iphonedevsdk.com/."]http://www.iphonedevsdk.com/[/url] and [url="https://discussions.apple.com/thread/3258943"]https://discussions..../thread/3258943[/url].

Share this post


Link to post
Share on other sites
polyfrag    2502
I started a new OpenGL ES project and added AVFoundation framework and

[code]#import <AVFoundation/AVAudioPlayer.h>
#import <AudioToolbox/AudioServices.h>[/code]

and

[code]- (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];
}[/code]

and added /sounds/ to the project, but it still doesn't work on my iPhone.

Here is the project:

[url="http://corpstates.myftp.org/downloads/testApp.zip"]http://corpstates.my...ads/testApp.zip[/url]






SOLVED: my phone ring switch was set to mute.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this