2
我已經添加了這個代碼到viewDidLoad
方法播放背景視頻!我如何在iOS視圖背景中播放視頻? (使用故事板)的iOS在視圖
我已經添加了這個代碼到viewDidLoad
方法播放背景視頻!我如何在iOS視圖背景中播放視頻? (使用故事板)的iOS在視圖
它看起來像你創建的MPMoviePlayerController實例在回放過程中受ARC影響。
嘗試製作MPMoviePlayerController的強屬性並在開始播放之前指定您在其中創建的實例。
所以,你的代碼看起來像這樣
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"myvid" ofType:@"m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
//set the frame of movie player
self.moviePlayer.view.frame = CGRectMake(0, 0, 200, 200);
[self.view addSubView:self.moviePlayer.view];
[self.moviePlayer play];