Hello,
I have several UIButtons that control the iPhone's music player.
I would like to have the music player seek backwards if the previous button is touched and held, but skip to the previous item if the button is single-tapped.
Currently, I am able to skip to the previous item with a tap, but touching and holding will seek backwards AND skip to the previous item once the button is touched up.
Here is the code I am currently using:
- (void)previousButtonTouchedDown {
[self performSelector:@selector(seekBackwards) withObject:nil afterDelay:1];
}
- (void)previousButtonTouchedUpInside {
MPMusicPlaybackState playbackState = self.iPodPlayer.playbackState;
if (playbackState == MPMusicPlaybackStateSeekingBackward) {
[self.iPodPlayer endSeeking];
} else {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(seekBackwards) object:nil];
[self.iPodPlayer skipToPreviousItem];
}
}
- (void)seekBackwards {
[self.iPodPlayer beginSeekingBackward];
}
How can I seek forward, but not skip to the previous item, if the button is touched, held, then touched up?
Thanks.