iPhone应用程序:如何使用MPMoviePlayerController在应用程序中播放Youtube视频 [英] iPhone App :How to play Youtube video in app using MPMoviePlayerController
本文介绍了iPhone应用程序:如何使用MPMoviePlayerController在应用程序中播放Youtube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
iPhone应用程式:如何使用MPMoviePlayerController在应用程式中播放YouTube影片
代码:
NSString * urlAddress = @http://www.youtube.com/xyz;
NSLog(@URL ADDress:%@,urlAddress);
//创建一个URL对象。
NSURL * url = [NSURL URLWithString:urlAddress];
movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
movie.scalingMode = MPMovieScalingModeAspectFill;
movie.view.frame = CGRectMake(0.0,0.0,320.0,460.0);
[self.view addSubview:movie.view];
[movie play];
如果我通过正在播放视频的本地目录的URL
NSString * filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@Video.mp4];
NSURL * url = [[[NSURL alloc] initFileURLWithPath:filePath] autorelease];如何直接从youtube网址播放视频到MPMoviePlayerController?
它们使用隐藏的UIWebView:
$ b b http://www.iphonedevsdk。 com / forum / iphone-sdk-development / 61447-how-play-youtube-movie.html
iPhone App :How to play Youtube video in app using MPMoviePlayerController
for that i write the code:
NSString *urlAddress = @"http://www.youtube.com/xyz";
NSLog(@"URL ADDress : %@",urlAddress);
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
movie.scalingMode=MPMovieScalingModeAspectFill;
movie.view.frame = CGRectMake(0.0, 0.0, 320.0, 460.0);
[self.view addSubview:movie.view];
[movie play];
if i pass the url of local directory it is playing video
NSString* filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Video.mp4"];
NSURL* url = [[[NSURL alloc] initFileURLWithPath:filePath] autorelease];
How can I play video directly from youtube url to MPMoviePlayerController?
解决方案
There is a great thread that on IphoneDevSDk.
They work with a hidden UIWebView: http://www.iphonedevsdk.com/forum/iphone-sdk-development/61447-how-play-youtube-movie.html
这篇关于iPhone应用程序:如何使用MPMoviePlayerController在应用程序中播放Youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文