2014-04-04 57 views
0

我需要對ios中導入的YouTube視頻網址進行說明。我的場景是,我創建了一個tableview,當我點擊它將導航到我的Detailviewcontroller的單元格。詳細viewviewcontroller頁面我有一個UIButton,當我點擊該按鈕,它會播放視頻。此視頻網址包含youtube視頻網址。它在3天前工作正常。現在它不工作。我不知道我在代碼中犯了什麼錯誤。Youtube視頻在ios中有時無法工作

我的代碼是: DetailViewController.m

-(IBAction)YouTube:(id)sender 
{ 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; 
    PlayViewController *PVC = [storyboard instantiateViewControllerWithIdentifier:@"PlayViewController"]; 
    PVC.videourl=strVideoURL; 
    [self.navigationController pushViewController:PVC animated:YES]; 
} 

PlayViewController.m

-(void)viewDidLoad 
{ 
    NSArray *arr=[YoutubeParser parseHTML:videourl]; 
    NSString *myArrayString = [arr objectAtIndex:0]; 
    videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:myArrayString]; 
    [self presentMoviePlayerViewControllerAnimated:videoPlayerViewController]; 
    NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter]; 
    [defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; 
    [defaultCenter addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; 
    [defaultCenter addObserver:self selector:@selector(moviePlayerLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; 

} 
+0

使用UIWebView播放YouTube視頻,那麼你將不會面對這些問題 – Babul

回答