0
我知道,有幾十個類似的問題。我全部閱讀,仍然無法找到答案。 我用presentModalViewController
方法顯示視頻與視頻。當用戶進行滑動時,我希望下一個視頻在同一個播放器中開始。但是,當我嘗試更改視頻播放器的contentURL
時,視圖會消失 - 就像dismissModalViewControllerAnimated
方法被調用一樣(但事實並非如此)。當播放器contentURL發生變化時MPMoviePlayerViewController消失
@implementation ViewController
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if(!moviePlayerViewController)
{
NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"];
moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
UISwipeGestureRecognizer *leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)];
leftSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[moviePlayerViewController.view addGestureRecognizer:leftSwipeRecognizer];
[self presentModalViewController:moviePlayerViewController animated:YES];
}
}
-(void)leftSwipe:(id)sender
{
moviePlayerViewController.moviePlayer.contentURL =
moviePlayerViewController.moviePlayer.contentURL; // no matter what exactly URL here.
[moviePlayerViewController.moviePlayer play]; // view disappears even before this line is reached
}
@end