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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 10-10-2009, 02:10 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Pune, India
Posts: 314
Send a message via Skype™ to Akshay Shah
Question Play 10 sounds one after another... How???

Hi all..
I need some help regarding audio playing...

I have 10 sound files in my bundle.
So i need to play them one after another..
How can i do that?
__________________
If you think I did help you, you can always thank me by buying
iHoldMore - A very nice and addictive game...

Need a mobile app. Contact Us.
Ruby Solutions Pvt. Ltd.
You can mail me at akshay@ruby-solutions.com
Akshay Shah is offline   Reply With Quote
Old 10-10-2009, 09:58 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,049
Default

Quote:
Originally Posted by Akshay Shah View Post
Hi all..
I need some help regarding audio playing...

I have 10 sound files in my bundle.
So i need to play them one after another..
How can i do that?
You know how to play one sound I assume. So then just create a loop. Maybe get the sound filename from an array and then bob's your uncle.
wuf810 is offline   Reply With Quote
Old 10-10-2009, 10:14 PM   #3 (permalink)
Registered Member
 
jamesbrannan's Avatar
 
Join Date: Aug 2008
Location: Gaithersburg, MD
Posts: 178
Default

Quote:
Originally Posted by Akshay Shah View Post
Hi all..
I need some help regarding audio playing...

I have 10 sound files in my bundle.
So i need to play them one after another..
How can i do that?
Create an array, play the first item in array, when done it calls the audioPlayerDidFinishPlaying and then play the next item in the array....

Works like a charm. I have an App, iNtervalTunes, that uses this technique and it works.

Some of this code is relevant, some isn't...basically create an array and then keep playing items in array until done, and then when each one is done, this method is called. Don't forget that your class has to implement the audio player's delegate. They play one after the other.

James A. Brannan
iPhone SDK Programming, A Beginner's Guide.

Code:
// not compilable, mixed together to give you the idea...


@interface WorkoutVoiceHolder : NSObject <AVAudioPlayerDelegate>
NSMutableArray * theSoundQueue;
@property (nonatomic,retain) NSMutableArray * theSoundQueue;

NSMutableArray * soundsQueue = [[[NSMutableArray alloc] init] autorelease];


[((AVAudioPlayer*)[self.theSoundQueue objectAtIndex:0]) play];


- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{

	[player release];
	
	////////NSLog(@"in audioPlayerDidFinishPlaying...");
	
	if([self.theSoundQueue count] > 0)
	{
		[self.theSoundQueue removeObjectAtIndex:0];
	}
	
	if([self.theSoundQueue count]< 1)
	{	
		AudioSessionSetActive(false);		
		[[NSNotificationCenter defaultCenter] postNotificationName:@"audioPlayerNotPlaying" object:nil];
		isCurrentlyPlaying = NO;	
		return;
	}
					
	
	[((AVAudioPlayer*)[theSoundQueue objectAtIndex:0]) play];
	
}
jamesbrannan is offline   Reply With Quote
Old 10-10-2009, 10:16 PM   #4 (permalink)
Beast Iphone Developor
 
justill45's Avatar
 
Join Date: Aug 2009
Location: Atlanta, Georgia
Age: 16
Posts: 1,302
Default

Quote:
Originally Posted by Akshay Shah View Post
Hi all..
I need some help regarding audio playing...

I have 10 sound files in my bundle.
So i need to play them one after another..
How can i do that?

when u say 1 after another, do u want:

1. a button to play one, then immediatly play the next after its done
2/ do u want them to just play 1 after another when u start the app
3. do u want a sound to play when u press a button, then the next sound to play after u press the button, etc...
justill45 is offline   Reply With Quote
Old 11-19-2010, 02:17 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 10
Default

I developped an application similar to yours. I used an array and it works very well.
sebastien is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, play, queue, 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: 265
18 members and 247 guests
ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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