¿Cómo insertar información de encabezado en la url MPMoviePlayerController?
Necesito implementar el servicio de video streaming con protocolo http. Sé cómo configurar url en MPMoviePlayerController y cómo configurar headerField en NSMutableURLRequest, pero no tengo idea de cómo combinarlos. Implemento como el código de abajo, pero no funciona, y asumo que no hay información de archivo en los datos binarios.
- (void) openUrl
{
NSMutableURLRequest *reqURL = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:@"http://111.222.33.44/MOV/2013/4/123123123"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
[reqURL setHTTPMethod:@"GET"];
[reqURL setValue:@"Mozilla/4.0 (compatible;)" forHTTPHeaderField:@"User-Agent"];
[reqURL setValue:@"AAA-bb" forHTTPHeaderField:@"Auth-Token"];
[reqURL setValue:@"bytes=0-1024" forHTTPHeaderField:@"Range"];
[reqURL setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[NSURLConnection connectionWithRequest:reqURL delegate:self];
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSLog(@"Received");
NSError * jsonERR = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myMove.ts"];
[data writeToFile:path atomically:YES];
NSLog(@"copied");
NSURL *moveUrl = [NSURL fileURLWithPath:path];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]init];
[player setContentURL:moveUrl];
player.view.frame = self.view.bounds;
player.controlStyle = MPMovieControlStyleEmbedded;
[self.view addSubview:player.view];
[player play];
}
Confirmé que hay datos en el método de delegado, pero no sé cómo reproducirlos. Por favor, que alguien me haga saber cómo jugarlo. Auth-Token y Range son parámetros necesarios.
Gracias.