Question

Here i want to create a custom uislider which is similar to media player forward and backward ie programatically moving slider at a particular time interval.

for example consider am having a video for this video i need to implement slider to controller to move forward and backward of video content.

any samples and tutorials.

thanks....

Was it helpful?

Solution

This might be of interest to you;

UISlider with ProgressView combined

OTHER TIPS

Here is a code which will work as a progress bar like moviePlayerController

I Hope This code will help you

// .M 

@property (nonatomic,strong)UISlider *slider1;

- (void)viewDidLoad
{
    [super viewDidLoad];

    slider1 = [[UISlider alloc] initWithFrame:CGRectMake(10, 400, 300,30)];

    [slider1 setBackgroundColor:[UIColor clearColor]];
    slider1.maximumValue =  1.0;
    slider1.minimumValue = 0.0;
    slider1.continuous = YES;
    [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(updateSlider1) userInfo:nil repeats:YES];
    [slider1 addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:slider1];
    [self.view bringSubviewToFront:slider1];
}

// this method seek video

-(void)sliderAction:(id)sender
{
    float currentValue,TotalValue;
    float value;
    currentValue = self.moviePlayerController.currentPlaybackTime;
    TotalValue = self.moviePlayerController.duration;

    value =self.moviePlayerController.currentPlaybackTime = slider1.value * TotalValue;

}


// Update slider value after each 0.2 sec 
- (void)updateSlider1 {


    float currentValue,TotalValue;
    float value;
    currentValue = self.moviePlayerController.currentPlaybackTime;
    TotalValue = self.moviePlayerController.duration;

   value = (currentValue/TotalValue);

    slider1.value = value;

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top