Discussion Forums  >  Uncategorized

Replies: 3    Views: 310

Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
08/14/11 08:32 PM (14 years ago)

How to add a Timer Countdown to audio tracks?

Im working on a basic sound app where I want the users to be able to press an icon to hear a sound (say of the ocean or wind etc...) Can anyone tell me or point me in the right direction as to how to include a timer? For example a picker or some function like play track for one hour and then stop, or turn off app Thanks
 
Parker @ buzztouch
buzztouch Evangelist
Profile
Posts: 1395
Reg: May 09, 2011
Pacific Grove, ...
24,500
like
08/14/11 11:00 PM (14 years ago)
A google search for 'Objective C Timer' turns up tons of results. Take what you can learn from them and what David told you on how to select a specific screen (in the post where you were trying to get songs to loop) and see if you can get something basic running. Repost how it goes for ya.
 
Jennyapps
I hate code!
Profile
Posts: 222
Reg: Jun 12, 2011
Tasmania, Austr...
4,870
like
08/14/11 11:25 PM (14 years ago)
Thanks I was trying to Google NSTimer so that was wrong I guess? Im off (again) to search the net. Appreciate the guidance Parker :)
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/15/11 11:23 PM (14 years ago)
In English: a) Create an NSTimer property in the .h file of whatever..like BT_screen_audio.m b) In the .m file (BT_screeen_audio.m) @synthesize the property (like all the other properties you see synthesized) c) Write a method to fire every second or so that magically figures out how long the songs been playing? b) When the screen loads, start the timer and set it to repeat...something like: [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(yourCoolMethod:) userInfo:nil repeats:YES]; Inside the method you create (yourCoolMethod in this case) you'll need a way to check how long this process has been happening. When the time-runs-out, trigger another method, like 'stopAudio' or 'kill app' or whatever.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.