无法在iOS中播放Youtube的电影

时间:2015-08-10 11:16:43

标签: ios iphone iphone-developer-program

来自互联网的视频如下:

NSURL *url = [NSURL URLWithString:@"http://www.example.com/myvideo.m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; 
[player play];

无法在模拟器黑屏显示上播放电影

1 个答案:

答案 0 :(得分:0)

您应该尝试一些框架(例如HCYoutubeParser),它们可以为您提取Youtube视频的直接链接。

// Gets an dictionary with each available youtube url
NSDictionary *videos = [HCYoutubeParser h264videosWithYoutubeURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=8To-6VIJZRE"]];

// Presents a MoviePlayerController with the youtube quality medium
MPMoviePlayerViewController *mp = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[videos objectForKey:@"medium"]]] autorelease];