如何在MPMoviePlayerController中打开Youtube视频并播放 [英] How to Open Youtube video in MPMoviePlayerController and Play it

查看:93
本文介绍了如何在MPMoviePlayerController中打开Youtube视频并播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在1次之前使用此方法.但是现在我无法从该URL获取在MPMoviePlayerController中直接播放YouTube视频的视频.

i use this method before 1 time. but Now i can not get video from this URL that direct-play YouTube video in MPMoviePlayerController.

URL = http://www.youtube.com/watch?v= JPUWNcGDyvM& feature = player_embedded

- (void)viewDidLoad
{

   player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.youtube.com/watch?v=JPUWNcGDyvM&feature=player_embedded"]]];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(movieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];

//---play movie---
[player prepareToPlay];
[player pause];

player.view.frame = CGRectMake(0, 0, 320, 367);

[self.view addSubview:player.view];   

[super viewDidLoad];

}

而我的movieFinishedCallback则为Under ...

and My movieFinishedCallback is as Under ...

- (void) movieFinishedCallback:(NSNotification*) aNotification 
{ 
 player = [aNotification object];
[[NSNotificationCenter defaultCenter]
 removeObserver:self
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];
}

推荐答案

如果可能的话,将您的URL打开到UIWebview中,然后在您的类中单击一个按钮并将其重定向到WebsiteViewController类,可能会有所帮助你

if possible to open your URL into UIWebview then take a button in your class and redirect it on to the WebsiteViewController class may be it helps u

WebsiteViewController.h///----

WebsiteViewController.h ///----

 @interface WebsiteViewController : UIViewController <UIWebViewDelegate>
 {
  IBOutlet UIWebView *webView;
 }

 @property(nonatomic,retain) IBOutlet UIWebView *webView;

WebsiteViewController.m///---

WebsiteViewController.m ///---

-(void)viewDidLoad {
 NSURLRequest *request = [[NSURLRequest alloc] initWithURL:@"url"];
 [self.webView setScalesPageToFit:YES];
 [self.webView loadRequest:request];
 [request release]; 
}

这篇关于如何在MPMoviePlayerController中打开Youtube视频并播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆