This post have a sample working code for show progress view when the audio is playing by using AVAudioplayer.
First declare the progress view in to your .h file
IBOutlet UIProgressView *progressAudio;
Next call this progressAudio in to your .m file
@Synthesize progressAudio;
Then add the following in to where the audio start to play
//For Progress View
NSTimer * myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateProgressView)
userInfo:nil
repeats:YES];
And finally updateProgressView method,
- (void)updateProgressView{
float totalTime=self.appSoundPlayer.duration;
float fltTime=self.appSoundPlayer.currentTime / totalTime;
progressAudio.progress=fltTime;
}
NSTimer * myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateProgressView)
userInfo:nil
repeats:YES];
And finally updateProgressView method,
- (void)updateProgressView{
float totalTime=self.appSoundPlayer.duration;
float fltTime=self.appSoundPlayer.currentTime / totalTime;
progressAudio.progress=fltTime;
}
That's all. If this post is useful for you , please share this to your friends. Thanks!
0 comments:
Post a Comment
Share your thoughts here...