iPhone 应用程序:如何使用 MPMoviePlayerController 在应用程序中播放 Youtube 视频
iPhone 应用程序:如何使用 MPMoviePlayerController 在应用程序中播放 Youtube 视频,
为此我编写了代码:
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];
如果我传递本地目录的 url,它正在播放视频
NSString* filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Video.mp4"];
NSURL* url = [[[NSURL alloc] initFileURLWithPath:filePath] autorelease];
如何直接从 youtube url 播放视频到 MPMoviePlayerController?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IphoneDevSDk 上有一个很棒的线程。
他们使用隐藏的 UIWebView:
http://www.iphonedevsdk.com /forum/iphone-sdk-development/61447-how-play-youtube-movie.html
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
检查此项并释放控制器。
Check this and release the controller.