-2
當ARC打開時,我無法播放視頻(視頻永久加載)。當ARC關閉時,我可以成功播放視頻。我不知道爲什麼以及如何編輯我的代碼與ARC on.Here播放視頻是我的代碼ARC使播放視頻失敗
-(IBAction)playMovie:(id)sender
{
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"big-buck-bunny-clip" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
}
- (void)moviePlaybackComplete:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];
}
你需要一個參考存到自己的MPMoviePlayerController或將在「的playMovie」年底被釋放 – borrrden
見borrrden的評論和使用搜索功能...此問題已在SO上多次提出並解答。例如http://stackoverflow.com/questions/11365791/mpmovieplayercontroller-not-playing-any-video-content-due-to-arc-and-memory-man – Till