我正在尝试使用 MPMovieplayercontroller 播放电影。除了“ initialPlaybackTime ”之外,一切都很好。玩家不是从给定的秒数开始播放,而是从头开始播放。
如何使“initialPlaybackTime”工作?
-(void)viewDidLoad
{
[super viewDidLoad];
NSString *moviePath= [[NSBundle mainBundle] pathForResource:@"02_Skater" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:moviePath] ;
// video player
playerViewController = [[MPMoviePlayerController alloc] init];
playerViewController.contentURL = url;
playerViewController.view.frame = CGRectMake(0, 200, 300, 300);
playerViewController.scalingMode = MPMovieScalingModeAspectFit;
playerViewController.initialPlaybackTime = 3;
playerViewController.endPlaybackTime = 4;
playerViewController.controlStyle=MPMovieControlStyleNone;
[playerViewController prepareToPlay];
[playerViewController play];
[[self view] addSubview: [playerViewController view]];
// Do any additional setup after loading the view, typically from a nib.
}