Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 11-04-2011, 04:08 PM   #1 (permalink)
Registered Member
 
aceiswild's Avatar
 
Join Date: Oct 2011
Location: Canada
Posts: 62
aceiswild is on a distinguished road
Default NSTimer and UIPicker sounds

I have a few audio files in a UIPickerView and when i select a sound and push a button it plays fine. But now I'm trying to integrate an NSTimer... So basically you select the sound you want from the UIPicker and press the start button for the NSTimer and when it counts to zero it plays that selected sound. I can get it to work perfectly with a single audio file but I'm having some troubles with multiple files. They are all arrays.
Any suggestions of tips on how i can get this to function with multiple arrays? Anything will help! It has no errors when i run but crashes when the timer gets to zero.

Here is my starting point with the NSTimer and array selection.

Code:
-(void) countDown {
    NSString* buf=[[NSString alloc] initWithFormat:@"%d", count];
    count--;
    countLabel.text = buf;
    [buf release];
    if(count == -1) { 
        
	
               NSString *path = [[NSBundle mainBundle] pathForResource: [arraySound objectAtIndex:1]  ofType:@"wav"];
        SystemSoundID soundID;
        AudioServicesCreateSystemSoundID((CFURLRef) [NSURL fileURLWithPath:path]
                                         , &soundID);
        AudioServicesPlaySystemSound (soundID);
        

        countLabel.text = @"    ";
        label3.backgroundColor = [UIColor clearColor];
        [myTimer invalidate];
    }
    
}

-(IBAction)countDown:(id)sender {
	count = 10;
    label3.backgroundColor = [UIColor lightGrayColor];
	myTimer =[NSTimer scheduledTimerWithTimeInterval: 1 
                                              target:self selector:@selector(countDown) 
                                            userInfo:nil 
                                             repeats:YES];
}
aceiswild is offline  
Old 11-04-2011, 05:33 PM   #2 (permalink)
Super Moderator
 
Join Date: Jan 2011
Posts: 434
Rhade is on a distinguished road
Default

Don't make duplicate threads.
__________________
Do not quote questionable posts.
Do not post moderator requests in public. Report the post or send a PM.
<----- Use the red flag button to report posts.
Rhade is offline  
Closed Thread

Bookmarks

Tags
array, picker, sound, timer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 415
17 members and 398 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, dre, FrankWeller, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, n00b, pbart, reficul, Retouchable, Sami Gh, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0