0
재생되는 동영상의 볼륨을 변경하고 싶습니다. 내가 MPVolumeView를 사용해야한다는 것을 알고, 다음 코드는 ios 6.1 (ipod touch 4g에서 테스트)에서 완벽하게 작동했지만 ios 8.1 (시뮬레이터 버전 8.1 (550.3))에서는 작동하지 않습니다. - 볼륨 슬라이더가 나타나지 않습니다. . 내가 놓친 것을 도와주세요.MPVolumeView가 ios 8에서 작동하지 않습니다.
#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController()
@property (retain, nonatomic) MPMoviePlayerController *player;
@property (retain, nonatomic) MPVolumeView *volumeView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *movieUrl = [[NSBundle mainBundle] URLForResource:@"IMG_0001" withExtension:@"MOV"];
self.player = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl];
self.player.view.frame = self.view.bounds;
// Here is where you set the control Style like fullscreen or embedded
self.player.controlStyle = MPMovieControlStyleEmbedded;
self.player.scalingMode = MPMovieScalingModeAspectFit;
self.player.allowsAirPlay = YES;
[self.view addSubview:self.player.view];
[self.player prepareToPlay];
[self.player play];
self.volumeView = [ [MPVolumeView alloc] init];
[self.volumeView setShowsVolumeSlider:YES];
[self.volumeView setShowsRouteButton:YES];
self.volumeView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 30);
// show volume view border
self.volumeView.layer.borderColor = [[UIColor redColor] CGColor];
self.volumeView.layer.borderWidth = 1.0f;
// next 6 lines - is my try to add slider images, but no luck again
UIImage *sliderThumbImage = [UIImage imageNamed:@"sliderthumb.png"];
UIImage *sliderMinTrackImage = [UIImage imageNamed:@"slidermintrack.png"];
UIImage *sliderMaxTrackImage = [UIImage imageNamed:@"slidermaxtrack.png"];
[self.volumeView setMinimumVolumeSliderImage:sliderMinTrackImage forState:UIControlStateNormal];
[self.volumeView setMaximumVolumeSliderImage:sliderMaxTrackImage forState:UIControlStateNormal];
[self.volumeView setVolumeThumbImage:sliderThumbImage forState:UIControlStateNormal];
[self.view addSubview:self.volumeView];
}
@end
P. xCode 6.1
실제로 내가 소유하고있는 장치를 제외하고는 레이아웃을 테스트 할 수 없기 때문에 애플은 적어도 시뮬레이터 용으로 위조품을 제공해야합니다. 즉 적어도 6 개의 iPhone (6 세 이상, 6 세 이상)과 하나의 iPad가 필요합니다. – gnasher729