Hi all,
I am working with audio player application, here i am having upto 15 songs i collected all the names into array and playing one by one as following,
- (void)audioPlayerDidFinishPlaying
AVAudioPlayer *)player successfully
BOOL)flag
{
if(prayerArray != nil)
{
int totalPrayersInQueue = [prayerArray count];
if(currentPlayingSongIndex < totalPrayersInQueue-1 )
{
currentPlayingSongIndex++;
NSString *sound = [prayerArray objectAtIndex:currentPlayingSongIndex];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:sound ofType
"mp3"]] error:nil];
player.delegate = self;
self.audioPlayer = player;
[player release];
// Set a timer which keep getting the current music time and update the UISlider in 1 sec interval
progressTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector
selector(updateSlider) userInfo:nil repeats:YES];
// Set the maximum value of the UISlider
progressSlider.maximumValue = audioPlayer.duration;
//NSLog(@"Current Song Duration %i",intValue(audioPlayer.duration));
// Set the valueChanged target
[progressSlider addTarget:self action
selector(sliderChanged
forControlEvents:UIControlEventValueChanged];
// Play the audio
[audioPlayer prepareToPlay];
[audioPlayer play];
}
else {
[playButton setImage:[UIImage imageNamed
"Play_icon.png"] forState:UIControlStateNormal];
}
}
}
Here i want to introduce a delay of 15 seconds between each songs, is there a way and how to do that inside a delegate method.
Thanks in advance.
Regards
sakthi
I am working with audio player application, here i am having upto 15 songs i collected all the names into array and playing one by one as following,
- (void)audioPlayerDidFinishPlaying
{
if(prayerArray != nil)
{
int totalPrayersInQueue = [prayerArray count];
if(currentPlayingSongIndex < totalPrayersInQueue-1 )
{
currentPlayingSongIndex++;
NSString *sound = [prayerArray objectAtIndex:currentPlayingSongIndex];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:sound ofType
player.delegate = self;
self.audioPlayer = player;
[player release];
// Set a timer which keep getting the current music time and update the UISlider in 1 sec interval
progressTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector
// Set the maximum value of the UISlider
progressSlider.maximumValue = audioPlayer.duration;
//NSLog(@"Current Song Duration %i",intValue(audioPlayer.duration));
// Set the valueChanged target
[progressSlider addTarget:self action
// Play the audio
[audioPlayer prepareToPlay];
[audioPlayer play];
}
else {
[playButton setImage:[UIImage imageNamed
}
}
}
Here i want to introduce a delay of 15 seconds between each songs, is there a way and how to do that inside a delegate method.
Thanks in advance.
Regards
sakthi