In my application i get the links of video from server in UITableview .all these link are store on Sever in Textfile,i get all these link from sever one by one and assign each to cell in UITableview.all these i done succefully but i want when i click on any cell in UITableview its play the video in next view.here is my code.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
nextview *dvController = [[nextview alloc] initWithNibName:@"nextview" bundle:nil];
[self presentModalViewController:dvController animated:YES];
strFile = [Listdata objectAtIndex:indexPath.row];
NSLog(@"test=%@",strFile);
[dvController release];
}
and in next view i assign the link which i store in “strFile” to MPMoviePlayerController here is my code.
-(void)viewDidAppear:(BOOL)animated
{
NSLog(@"mytest=%@",strFile);
NSURL *url = [NSURL URLWithString:strFile];
NSLog(@"myurl=%@",url);
myplayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
myplayer.view.frame = CGRectMake(0, 0,900, 700);
[self.view addSubview:myplayer.view];
[myplayer play];
}
In NSlog i see the link but its not play in MPMoviePlayerController.Any one can guide me that what mistake i make.thanx in advance.
You probably shouldn’t be setting the frame and adding to the subview, You may be confused with
MPMoviePlayerViewController. Try this…EDIT disregard my code, you can’t directly play a YouTube video in MPMoviePlayerController. Check this Post instead Play YouTube videos with MPMoviePlayerController instead of UIWebView