Reputation: 35
I am Developing an ios app for audio player.
Here now i have to move one slider that represents the current playing track of the song
For Example my song duration is 6sec now i have to move the slider from x point =0 to x=480 by the time audio playing should Finnish it paying one loop. I am moving the based up Nstimer. now i required the nstime interval for nstimer to move the slider correctly to end that is x=480.
myTimer = [NSTimer scheduledTimerWithTimeInterval:timeinterval target:self selector:@selector(updatplayer) userInfo:nil repeats:YES]; here i need this timeinterval value
can any one help me ?
Upvotes: 0
Views: 740
Reputation: 66
You can use your timer as:
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updatplayer) userInfo:nil repeats:YES];
- (void)updatplayer {
long currentPlaybackTime = moviePlayer.currentPlaybackTime;
playSlider.value = currentPlaybackTime / moviePlayer.duration;
}
Upvotes: 0
Reputation: 6844
You can set your time interval as a class property and access it from there. In example:
@interface YourClass ()
@property (nonatomic, assign) NSTimeInterval myTimeInterval);
@end
@implementation YourClass
- (void)methodWithYourTimerInIt {
// ... Do stuff
self.myTimeInterval = 6.0;
myTimer = [NSTimer scheduledTimerWithTimeInterval:self.myTimeInterval target:self selector:@selector(updatePlayer) userInfo:nil repeats:YES];
}
- (void)updatePlayer {
NSLog(@"My time interval is: %f", self.myTimeInterval);
}
@end
Upvotes: 0