0

我正在解析一个包含您的电子管提要的 json 提要,我在其中尝试在固定框架中播放 youtube。当我单击按钮时,我得到黑色背景,你们可以帮助我吗?下面是代码

-(void)watchClip:(id)sender
{
NSLog(@"hello how should this be:%@",URL);
 NSURL *fileURL=[NSURL URLWithString:[URL   stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];   
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];  
moviePlayerController.view.frame=CGRectMake(28,15,250,130);  
[[NSNotificationCenter defaultCenter] addObserver:self  
                                         selector:@selector(moviePlaybackComplete:)  
                                             name:MPMoviePlayerPlaybackDidFinishNotification  
                                           object:moviePlayerController];  
   //moviePlayerController.fullscreen = YES;  

  [v addSubview:moviePlayerController.view];

[moviePlayerController play];  

 }
4

1 回答 1

1

MPMoviePlayerController无法播放 YouTube 视频。改用 a UIWebView

使用 MPMoviePlayerController 而不是 UIWebView 播放 YouTube 视频

这是一个关于如何在固定框架中播放 youtube 视频的好教程。请注意,如果您在模拟器中运行,它将无法工作。

于 2012-08-02T13:21:30.570 回答