0

我正在为音频播放器开发一个 ios 应用程序。

现在我必须移动一个代表歌曲当前播放曲目的滑块

例如,我的歌曲持续时间为 6 秒,现在我必须将滑块从 x 点 = 0 移动到 x = 480 到音频播放的时间,芬兰应该支付一个循环。我正在移动基于 Nstimer。现在我需要 nstime 间隔让 nstimer 正确移动滑块以结束,即 x=480。

myTimer = [NSTimer scheduleTimerWithTimeInterval:timeinterval target:self selector:@selector(updatplayer) userInfo:nil repeats:YES]; 这里我需要这个时间间隔值

谁能帮我 ?

4

2 回答 2

0

您可以将时间间隔设置为类属性并从那里访问它。例如:

@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
于 2012-06-06T13:00:55.830 回答
0

您可以将计时器用作:

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;
}
于 2012-06-06T13:12:25.953 回答