Is there a way to customise the look or at least position of the movie progress slider on MPMovidePlayer?
3 回答
使用隐藏现有控件MPMovieControlStyle
,将其设置为MPMovieControlStyleNone
。
现在add
你custom control
的MPMoviePlayer's
观点。
将示例uislider-to-control-avaudioplayerMPMoviePlayer
与has相同currentPlaybackTime
请参阅mpmovieplayercontroller-buffering-state链接。
请参阅mpmovieplayercontroller-when-will-i-know-that-the-downloading-of-the-file-reach链接。
为此,您必须制作自己的自定义滑块。例如,您可以隐藏 MPMoviePlayerController 进度条并制作自己的自定义进度条您可以通过此代码隐藏 MPMoviePlayerController 进度条
moviePlayerController.controlStyle = MPMovieControlStyleNone;
然后您可以创建自定义进度条
UISlider *progressbar;
[progressbar setMinimumTrackImage:[UIImage imageNamed:@"min.png"] forState:UIControlStateNormal];//you can set the background for which you have progressed the video
[progressbar setMaximumTrackImage:[UIImage imageNamed:@"max.png"] forState:UIControlStateNormal];//you can set the background for which you have left the video
[progressbar setThumbImage:[UIImage imageNamed:@"thumb.png"] forState:UIControlStateNormal];//you can set the thumb image for you progress bar.
这将是滑块,您可以在线程中更新滑块的位置。
这是进度滑块的代码,例如 MPMoviePlayerController
“使用 NSTimer 平滑移动滑块作为 MPMoviePlayerController 进度条”
// 您可以根据需要更改 scheduleTimerWithTimeInterval
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateSlider) userInfo:nil repeats:YES];
“将 currentPlaybackTime 设置为 Slider 值”
- (void)updateSlider {
slider1.value = self.moviePlayerController.currentPlaybackTime;
}