1

我想在我的应用程序中使用以下代码来获取 UISlider 上的当前播放时间和总时间,我从这个链接获取代码。

   -(IBAction)sliding:(id)sender{

    CMTime newTime = CMTimeMakeWithSeconds(seeker.value, 1);
    [self.player seekToTime:newTime];
 }

-(void)setSlider{

    sliderTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0 target:self    selector:@selector(updateSlider) userInfo:nil repeats:YES]retain];
    self.seeker.maximumValue = [self durationInSeconds];
    [seeker addTarget:self action:@selector(sliding:) forControlEvents:UIControlEventValueChanged];
    seeker.minimumValue = 0.0;
    seeker.continuous = YES;  
}

- (void)updateSlider {

    self.seeker.maximumValue = [self durationInSeconds];
    self.seeker.value = [self currentTimeInSeconds];
}

- (Float64)durationInSeconds {
        Float64 dur = CMTimeGetSeconds(duration);
    return dur;
}


- (Float64)currentTimeInSeconds {
        Float64 dur = CMTimeGetSeconds([self.player currentTime]);
    return dur;
  }

但我不知道什么是seeker。我是 iOS 新手,我需要任何有关此问题的教程的建议。

4

2 回答 2

2
@property (strong, nonatomic) IBOutlet UISlider *seeker;
于 2013-01-28T11:43:16.613 回答
0

@邦德先生

- (Float64)currentTimeInSeconds {

double runningTime = CMTimeGetSeconds(_playerViewController.player.currentTime);
NSLog(@"currentTime %f",runningTime);

return dur;
}
于 2016-10-12T06:38:54.617 回答