2012-06-15 1 views
0

Я знаю, что есть десятки подобных вопросов. Я прочитал их все и до сих пор не мог найти ответа. Я показываю просмотр видео с помощью метода presentModalViewController. Когда пользователь делает салфетки, я хотел бы, чтобы следующее видео начиналось с того же игрока. Но когда я пытаюсь изменить contentURL видеопроигрывателя, вид исчезает - как если бы был вызван метод dismissModalViewControllerAnimated (но это не так).MPMoviePlayerViewController исчезает при изменении содержимого игрокаURL

@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 

ответ