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];
}
and My movieFinishedCallback
is as Under ...
- (void) movieFinishedCallback:(NSNotification*) aNotification
{
player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
}
if possible to open your
URL
intoUIWebview
then take a button in your class and redirect it on to theWebsiteViewController
class may be it helps uWebsiteViewController.h ///----
WebsiteViewController.m ///---
Create a custom uiwebview: please follow instruction
1) Create a interface .h file named "YouTubeView.h"
2) in to .m file
3) Import the youtubeview file in the controller where you want to play you tube video and create uiview like the code below
Note: Video will play in device only so check in device