-1

I've searched Google and StackOverflow for two days and have yet to find a clear, concise answer.

My goal is to create a slider/progress bar that allows the user to scrub to a different part of the song, with two labels on either side, one showing the elapsed time and the other, the time left on the song.

I'm using DiracAudioPlayer, which also incorporates AVAudioPlayer functionality. Any help or direction to a tutorial is greatly appreciated.

kylesimmonds
  • 183
  • 2
  • 11
  • 1
    I recognize you have a legitmate problem to solve, but this doesn't seem answerable in its current form - it doesn't have a question! Perhaps you could elaborate on what you have right now, and what you've tried to implement that failed. That will help others provide a more focused answer. – corsiKa Nov 14 '12 at 21:57
  • Thank you for your feedback. I used [this tutorial](http://eureka.ykyuen.info/2010/06/10/iphone-add-an-uislider-for-avaudioplayer/) originally, but using Dirac Audio I had several problems with undefined properties and such. – kylesimmonds Nov 19 '12 at 18:52

1 Answers1

3

Not sure if this is an issue with doing the scrubbing or updating the time elapsed so I'll show what I think you can do for both.

To update the progress bar and time labels, Apple does the following in their example project avTouch

updateTimer = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(updateCurrentTime) userInfo:player repeats:YES];
- (void)updateCurrentTime
{

    currentTime.text = [NSString stringWithFormat:@"%d:%02d", (int)self.player.currentTime / 60, (int)p.currentTime % 60, nil];
    progressBar.value = self.player.currentTime;
}

And then the seeking is simply done by setting the currentTime

- (IBAction)progressSliderMoved:(UISlider *)sender
{
    player.currentTime = sender.value;
    [self updateCurrentTimeForPlayer:player];
}
pturner
  • 686
  • 5
  • 14
  • Thank you for directing me to this! I have had some issues getting it to work with Dirac, but this is exactly what I was looking for. Thank you again. – kylesimmonds Nov 19 '12 at 18:53