|
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Junior Member
Join Date: Oct 2009
Posts: 1
|
I have a few instrumental audio tracks that I have set up as buttons on my View. How can I set it up to where if I am playing one track and then press another button then the first track should stop playing and the second should start. Here is the code I am using right now, not sure what to add to do to make it do so. Thanks in advance.
Code:
You must Login or Register to view and contribute code! This is done to increase participation in helping one another out, if you have been helped please pass on the favor. - (void)instrumentalone {
//play the result
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"instrumental1" ofType:@"wav"]] error:nil];
if (nil != player) {
[player setDelegate:self];
[player play];
} else {
NSLog(@"Failed to allocate AVAudioPlayer object!");
}
}
- (void)instrumentaltwo {
//play the result
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"instrumental2" ofType:@"wav"]] error:nil];
if (nil != player) {
[player setDelegate:self];
[player play];
} else {
NSLog(@"Failed to allocate AVAudioPlayer object!");
}
}
- (void)instrumentalthree {
//play the result
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"instrumental3" ofType:@"wav"]] error:nil];
if (nil != player) {
[player setDelegate:self];
[player play];
} else {
NSLog(@"Failed to allocate AVAudioPlayer object!");
}
}
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
if (flag == NO) NSLog(@"Playback finished successfully!");
[player setDelegate:nil];
[player release];
}
Last edited by kdp8791; 10-18-2009 at 02:54 AM. |
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Search Engine Friendly URLs by vBSEO 3.3.0 RC1 |




Linear Mode
