您可以更改 的默认控件MPMoviePlayerController
。您可以做的一件事是您可以隐藏默认控件MPMoviePlayerViewController
并添加您自己的自定义音量滑块。
moviePlayer.controlStyle=MPMovieControlStyleNone;
您可以像这样添加音量按钮:
UIButton *soundBtn=[ UIButton buttonWithType:UIButtonTypeCustom];
soundBtn.frame=CGRectMake(400,10,35,35);
soundBtn.showsTouchWhenHighlighted=YES;
[soundBtn setBackgroundImage:[UIImage imageNamed:@"valume.png"] forState:UIControlStateNormal];
[soundBtn addTarget:self action:@selector(valumeAction) forControlEvents:UIControlEventTouchUpInside];
[controllsView addSubview:soundBtn];
对于卷,您可以使用 MPVolumeView 类
-(void)volumeController{
volumeView = [[UIView alloc]initWithFrame:CGRectMake(40,410,100,20)];
volumeView.backgroundColor = [UIColor clearColor];
[self.view addSubview:volumeView];
//MP Valume Slider for controlling thew volume
volumeslider = [[[MPVolumeView alloc] initWithFrame:volumeView.bounds] autorelease];
NSArray *tempArray = volumeslider.subviews;
for (id current in tempArray){
if ([current isKindOfClass:[UISlider class]]){
UISlider *tempSlider = (UISlider *) current;
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"bar_2.png"]
stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [[UIImage imageNamed:@"bar.png"]
stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0];
[tempSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[tempSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
}
}
[volumeView addSubview:volumeslider];
//[controllsView addSubview:volumeView];
[volumeView sizeToFit];
volumeView.hidden = YES;
isValumeBarHidden = YES;
//Volume Slider created and added to the volumeview
}