In this tutorial I teach you how to add a duration slider that will allow the user to choose the time that the song plays from in your app.
Main Code:
In .h:
IBOutlet UISlider *positionSlider;
NSTimer *soundTimer;
(IBAction)changePosition;
(void) updateSlider;
In .m in viewDidLoad:
soundTimer = nil;
positionSlider.maximumValue = sound.duration;
positionSlider.minimumValue = 0;
sound.currentTime = positionSlider.value;
(IBAction)changePosition {
sound.currentTime = positionSlider.value;
}
(void) updateSlider {
[positionSlider setValue:sound.currentTime];
}
in playSound:
if (![sound isPlaying]) {
if (soundTimer == nil)
soundTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateSlider) userInfo:nil repeats:YES];
} else {
[soundTimer invalidate];
soundTimer = nil;
}
In resetSound:
positionSlider.value = sound.currentTime;
[soundTimer invalidate];
soundTimer = nil;
Twitter: / failcakeapps
Apple Developer Center: http://developer.apple.com/devcenter/...
Website: http://failcake.webs.com/
Channel: / milmersxcode
On this page of the site you can watch the video online iPhone Programming: Making Sounds-Adding a duration slider. with a duration of hours minute second in good quality, which was uploaded by the user MilmersXcode 21 October 2011, share the link with friends and acquaintances, this video has already been watched 1,208 times on youtube and it was liked by 7 viewers. Enjoy your viewing!