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

Reply
 
LinkBack Thread Tools Display Modes
Old 09-01-2010, 04:40 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Location: madrid
Age: 28
Posts: 1
ignicolist is on a distinguished road
Default Play sound and animate images

Hi, i search but i din`t find how to do it, so if anyone could help i appreciate. i want to play a list of sound files and animate images with each sound, the problem is that the animation only start animate when the sound finish play.

the code:

Code:
NSMutableArray *filmSound 
= [[NSMutableArray alloc] initWithObjects:
@"piano1.caf",@"piano2.caf",@"piano3.caf", 
@"piano4.caf",@"piano5.caf", @"piano6.caf", @"piano7.caf",  nil];
	
self.image.animationImages = 
[NSArray arrayWithObjects:[UIImage imageNamed:@"blueButton.png"],	
[UIImage imageNamed:@"blueButton2.png"],nil];
	
	
	
for (int i=0; i<7; i++) {
		
NSString *rowTitle = [filmSound objectAtIndex:i];
NSString *path =
[[NSBundle mainBundle] pathForResource:rowTitle ofType:nil];
		
	self.theAudio = [AVAudioPlayer alloc];
	if([theAudio initWithContentsOfURL:
[NSURL fileURLWithPath:path] error:NULL]) {
			[theAudio autorelease];
		}
		else {
			[theAudio release];
			theAudio = nil;
		}
		[self.theAudio setDelegate:self];
		
		[self.theAudio play];
		
		self.image.animationDuration = 1;
		self.image.animationRepeatCount = 1;
		[self.image startAnimating];	
		
		[NSThread sleepForTimeInterval:0.2];

i want in each interation to make one animation

Thnks
ignicolist is offline   Reply With Quote
Old 09-01-2010, 06:29 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 138
rrichar is on a distinguished road
Default

you need to include the whole .h and .m files. So we can see what you are imported into the project.
rrichar is offline   Reply With Quote
Old 09-01-2010, 06:38 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 19
blackknight467 is on a distinguished road
Default

switch the order around? play the sound after animating the image? do your sound files have a second or two of no sound before the actual sound?
blackknight467 is offline   Reply With Quote
Old 09-01-2010, 07:12 PM   #4 (permalink)
Fly-by-night Innovator
 
Join Date: Jun 2010
Posts: 364
musicwind95 is on a distinguished road
Default

Try one of NSObject's delay methods:

NSObject Class Reference
__________________
If I have helped you, please consider donating. I use PayPal. It would mean a lot to me!


For more iOS Development, check out my blog—Cups of Cocoa. All visitors welcome, but especially beginners!

Hope I have helped!

Please check out IceFall, a new action game available in the App Store!
musicwind95 is offline   Reply With Quote
Reply

Bookmarks

Tags
animation images, sound

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: 349
7 members and 342 guests
dre, freewind, hain, HemiMG, lendo, mottdog, oceanlablight
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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