我想播放带控件的电影 - 播放,停止,快进等。我使用此代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *movieUrl = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource:@"Spot"
ofType:@"mp4"]];
MPMoviePlayerController* myMovie=[[MPMoviePlayerController alloc]
initWithContentURL:movieUrl];
//disable scaling of our movie
myMovie.scalingMode = MPMovieScalingModeNone;
[myMovie.view setFrame: myView.bounds];
[myView addSubview: myMovie.view];
[[myMovie view] setFrame:[myView bounds]];
myMovie.initialPlaybackTime = 2.0;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
myMovie.scalingMode = MPMovieScalingModeAspectFill;
myMovie.controlStyle = MPMovieControlStyleEmbedded;
[myMovie play];
// Do any additional setup after loading the view from its nib.
}
电影有效,但没有控件。有人可以帮帮我吗?
答案 0 :(得分:0)
尝试这是否有效......
-(void)viewWillAppear:(BOOL)animated
{
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"Spot.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(0, 0, 300, 400);
[moviePlayer play];
}
您将获得所有控件。