我正在制作一个应用程序,我正在从url播放视频。我正在小窗口中显示该视频。我正在以横向模式播放视频。请看快照。
现在我有两个问题
播放视频的代码
NSURL *fileURL = [NSURL URLWithString:@"http://www.w3schools.com/html/movie.mp4"];
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
CGRect movieFrame;
movieFrame.size = self.videoView.frame.size;
[self.moviePlayerController.view setFrame:movieFrame];
[self.moviePlayerController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.videoView addSubview:self.moviePlayerController.view];
[self.videoView bringSubviewToFront:self.moviePlayerController.view];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeBottom
multiplier:1.0
constant:0.0]];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeTrailing
multiplier:1.0
constant:0.0]];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeLeading
multiplier:1.0
constant:0.0]];
[self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.videoView
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:0.0]];
[self.moviePlayerController play];