Como reproduzir o player de vídeo no ios
Eu quero poder clicar em um item do tableview e reproduzir o vídeo. Então, escrevi alguns códigos para o player de vídeo. Estou usando o MPMediaplayer framework. Estou usando o json parser. Usando o json parser para recuperar os dados do servidor da web. Meu problema é que quando um usuário clica em uma célula do UITableView é que o player de vídeo abre a tela inteira e diz apenas "loading ..." o tempo todo e o vídeo não carrega, nenhum erro é relatado no depurador. me qualquer corpo .. Agradecemos antecipadamente.
-(void)viewDidLoad
{
urlsArray=[NSMutableArray alloc]init];
}
-(void)loadData
{
url=[NSURL URLWithString:@"urls”];
NSMutableURLRequest *request=[[NSMutableURLRequest alloc]initWithURL:url];
[[NSURLConnection alloc]initWithRequest:request delegate:self];
[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible=NO;
NSError *jsonError = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&jsonError];
if ([jsonObject isKindOfClass:[NSArray class]])
{
}
else if ([jsonObject isKindOfClass:[NSDictionary class]])
{
NSDictionary *jsonDictionary = (NSDictionary *)jsonObject;
NSArray *array=[[NSArray alloc]init];
array=[jsonDictionary objectForKey:@"video-urls"];
dataDictionary=[array objectAtIndex:0];
NSLog(@"%@",dataDictionary);
}
[urlsArray addObject:[dataDictionary objectForKey:@“Key1”]];
[urlsArray addObject:[dataDictionary objectForKey:@“Key2”]];
[urlsArray addObject:[dataDictionary objectForKey:@“Key3”]];
[urlsArray addObject:[dataDictionary objectForKey:@“Key4”]];
[urlsArray addObject:[dataDictionary objectForKey:@“Key6”]];
NSLog(@"%@",urlsArray);
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
selectedIndex=indexPath.row;
NSLog(@"%@ %d",urlsArray,selectedIndex);
NSString *currentUrlsArr=[urlsArray objectAtIndex:indexPath.row];
NSURL *urlString=[NSURL URLWithString:currentUrlsArr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:urlString];
[self.view addSubview:moviePlayer.view];
moviePlayer.fullscreen = YES;
[moviePlayer play];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}