解决办法:
把 MPMoviePlayerController 类声明的 属性 定义成 全局变量就行了,为什么要这么做,我也不知道,这要问苹果公司了。
例代码:
#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController ()
@property (nonatomic, strong) MPMoviePlayerController *player ;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://101.200.231.179:2022/videos/2714/video.mp4"]];
self.player.controlStyle = MPMovieControlStyleNone;
self.player.shouldAutoplay = YES;
self.player.repeatMode = MPMovieRepeatModeOne;
[self.player setFullscreen:YES animated:YES];
self.player.scalingMode = MPMovieScalingModeAspectFit;
[self.player prepareToPlay];
[self.player.view setFrame:CGRectMake(10, 30, 300, 200)];
[self.view addSubview: self.player.view];
[self.player play];
}