我是一名新开发人员,因此我仍在学习并且知道我做错了一些事情。我有一个分段控制对象,当用户按下其中一个分段时,它会播放视频。我将它设置到他们按下片段的位置,然后必须按下播放按钮才能播放视频。我想剪掉播放按钮并让它自动播放。这就是我遇到麻烦的地方。我找到了 shouldAutoplay 选项,但是当我使用它并剪掉按钮时,它根本不会带我去看视频。我确定我没有正确使用 shouldAutoplay 选项。希望得到一些帮助,或者至少在正确的方向上有所帮助。
- (IBAction)playMovie:(id)sender;
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"mytestimony" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.shouldAutoplay = YES;
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie autorelease];
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
}