07-07-2010, 12:22 AM
#1 (permalink )
Registered Member
Join Date: Feb 2010
Location: Haverstraw, NY.
Posts: 94
problem on multiple sounds
hello, i am new to iphone dev, I have a problem, I have an app with 7 different sounds in the simulator works well, but on my iphone only hear the audio number 1.
This is the code, what is my mistake? thanks.
This is the viewcontroller.h
Code:
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
@interface AudioTimeViewController : UIViewController {
NSTimer *_timer;
NSTimer *_timer2;
NSTimer *_timer3;
NSTimer *_timer4;
NSTimer *_timer5;
NSTimer *_timer6;
NSTimer *_timer7;
}
@property (nonatomic,retain) NSTimer *_timer;
-(IBAction)audio1:(id)sender;
-(IBAction)audio2:(id)sender;
-(IBAction)audio3:(id)sender;
-(IBAction)audio4:(id)sender;
-(IBAction)audio5:(id)sender;
-(IBAction)audio6:(id)sender;
-(IBAction)audio7:(id)sender;
-(IBAction)preview1:(id)sender;
-(IBAction)preview2:(id)sender;
-(IBAction)preview3:(id)sender;
-(IBAction)preview4:(id)sender;
-(IBAction)preview5:(id)sender;
-(IBAction)preview6:(id)sender;
-(IBAction)preview7:(id)sender;
@end
This is the viewcontroller.m
Code:
#import "AudioTimeViewController.h"
@implementation AudioTimeViewController
@synthesize _timer;
- (void)dealloc{
[_timer invalidate];
[_timer release];
[_timer2 invalidate];
[_timer2 release];
[_timer3 invalidate];
[_timer3 release];
[_timer4 invalidate];
[_timer4 release];
[_timer5 invalidate];
[_timer5 release];
[_timer6 invalidate];
[_timer6 release];
[_timer7 invalidate];
[_timer7 release];
[super dealloc];
}
-(IBAction)audio1:(id)sender
{
if( _timer )
[_timer invalidate];
_timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio1) userInfo:nil repeats:NO];
}
-(void)audio1
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio1",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)audio2:(id)sender
{
if( _timer2 )
[_timer2 invalidate];
_timer2 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio2) userInfo:nil repeats:NO];
}
-(void)audio2
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio2",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)audio3:(id)sender
{
if( _timer3 )
[_timer3 invalidate];
_timer3 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio3) userInfo:nil repeats:NO];
}
-(void)audio3
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio3",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)audio4:(id)sender
{
if( _timer4 )
[_timer4 invalidate];
_timer4 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio4) userInfo:nil repeats:NO];
}
-(void)audio4
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio4",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)audio5:(id)sender
{
if( _timer5 )
[_timer5 invalidate];
_timer5 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio5) userInfo:nil repeats:NO];
}
-(void)audio5
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio5",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)audio6:(id)sender
{
if( _timer6 )
[_timer6 invalidate];
_timer6 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio6) userInfo:nil repeats:NO];
}
-(void)audio6
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio6",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
-(IBAction)audio7:(id)sender
{
if( _timer7 )
[_timer7 invalidate];
_timer7 = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(audio7) userInfo:nil repeats:NO];
}
-(void)audio7
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio7",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
//de aqui enpieza las pruebas del preview
- (IBAction)preview1:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio1",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)preview2:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio2",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)preview3:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio3",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)preview4:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio4",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)preview5:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio5",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)preview6:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio6",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)preview7:(id)sender
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"audio7",CFSTR("aif"),NULL);
if (soundFileURLRef) {
}
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}
// aqui terminan las pruebas del preview
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
@end
07-07-2010, 10:20 AM
#2 (permalink )
Registered Member
Join Date: Feb 2010
Location: Haverstraw, NY.
Posts: 94
Problem on multiple sounds
anyone can help me? I try to wav, caf, aif. Still problem
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 344
9 members and 335 guests
anothermine , bignoggins , Chickenrig , firecall , givensur , iNet , michaelhansen , Objective Zero , stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,893
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38