Reputation: 463
Actually i made that while song is playing in AVAudioPlayer, Slider is progressed as song running. Also i made if i seek it to forward or backward, from that position current song is playing. But the problem is after seeking the slider to particular position it not progressed and stop there but still song is running from that position.
The code below :
Blockquote
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateMyProgressOfCurrentPlayingSong:) userInfo:nil repeats:YES];
-(void)updateMyProgressOfCurrentPlayingSong:(NSTimer *)theTimer{
//For Current Song Playing Slider
float progr = [mediaPlayer currentTime]/[mediaPlayer duration];
self.audioCurrentPlayingSlider.value = progr;
}
//For Slider Value change
-(IBAction)audioCurrentSongPlayingSlider:(id)sender {
[myTimer invalidate];
myTimer = nil;
[self.audioCurrentPlayingSlider setMinimumValue:0.0];
[self.audioCurrentPlayingSlider setMaximumValue:[mediaPlayer duration]];
[mediaPlayer setCurrentTime:[self.audioCurrentPlayingSlider value]];
[myTimer methodForSelector:@selector(updateMyProgressOfCurrentPlayingSong:)];
}
Blockquote
Upvotes: 0
Views: 3691
Reputation: 7789
See following link which may help you, 1)How to add UISlider to AVPlayer 2)UISlider to control AVAudioPlayer 3)Create a UISlider progress bar and timer (like iPod player) within app 4)http://www.mobisoftinfotech.com/blog/iphone/integrate-music-player-in-iphone/
Upvotes: 1