-1
오디오 플레이어를 구현 중입니다. 하지만 내 슬라이더가 끌리지 않습니다.UISlider가 iOS를 끌지 않습니다.
/*
* Sets the current value of the slider/scrubber
* to the audio file when slider/scrubber is used
*/
- (IBAction)setCurrentTime:(id)scrubber {
//if scrubbing update the timestate, call updateTime faster not to wait a second and dont repeat it
NSLog(@"%@scrubber",@"drag");
[NSTimer scheduledTimerWithTimeInterval:0.01
target:self
selector:@selector(updateTime:)
userInfo:nil
repeats:NO];
[self.audioPlayer setCurrentAudioTime:self.currentTimeSlider.value];
self.scrubbing = FALSE;
}
/*
* Sets if the user is scrubbing right now
* to avoid slider update while dragging the slider
*/
- (IBAction)userIsScrubbing:(id)sender {
NSLog(@"%@",@"slider drag");
self.scrubbing = TRUE;
}
/*
* Updates the time label display and
* the current value of the slider
* while audio is playing
*/
- (void)updateTime:(NSTimer *)timer {
//to don't update every second. When scrubber is mouseDown the the slider will not set
if (!self.scrubbing) {
//self.currentTimeSlider.value = [self.audioPlayer getCurrentAudioTime];
}
NSLog(self.scrubbing ? @"Yes" : @"No");
if(self.scrubbing)
{
NSLog(@"%@ scrubbing",@"sdfs");
}
[self.currentTimeSlider addTarget:self
action:@selector(sliderDidEndSliding:)
forControlEvents:(UIControlEventTouchUpInside | UIControlEventTouchUpOutside)];
long currentPlaybackTime = [self.audioPlayer getCurrentAudioTime];
self.currentTimeSlider.value = currentPlaybackTime/[self.audioPlayer getAudioDuration];
self.timeElapsed.text = [NSString stringWithFormat:@"%@",
[self.audioPlayer timeFormat:[self.audioPlayer getCurrentAudioTime]]];
self.duration.text = [NSString stringWithFormat:@"%@",
[self.audioPlayer timeFormat:[self.audioPlayer getAudioDuration] - [self.audioPlayer getCurrentAudioTime]]];
}
이 슬라이더는 우리가 이전 위치로 이동 슬라이더를 드래그해도 드래그하지 않습니다 .H
@property (strong, nonatomic) IBOutlet UISlider *currentTimeSlider;
@property BOOL scrubbing;
하는 .m
. 왜 슬라이더가 드래그되지 않는지에 대한 아이디어.
감사합니다,
모든 아이디어 plssss – asifa