hi,
I'm trying to stream a video (H264) across a network on iOS. However, I'm getting the video data(NSData) into a buffer through an open socket to the remote server (using serverSocket), so I don't have a URL to the video that I can use to create an MPMoviePlayerController. How can I initialize and play the video on my iPhone/iPad in this way?
Here is the code:
NSString *requestString = textField_.text;
NSString *url = @"http://192.168.3.11:10000";
NSData *myRequestData = [NSData dataWithBytes:[requestString UTF8String] length:[requestString length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:myRequestData];
NSURLResponse *response = nil;
NSError *error = nil;
//send the request and get the response from the server.
NSData *content = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
pragma mark--
pragma mark--test video
//parse the content(NSData) into NSString.
NSString *string = [[NSString alloc] initWithData:content encoding:NSASCIIStringEncoding];
//and then into NSURL.
NSURL *url2 = [NSURL URLWithString:string];
//so that it can be used by MPMoivePlayerController.
player_ = [[MPMoviePlayerController alloc] initWithContentURL:url2];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback
name:MPMoviePlayerPlaybackDidFinishNotification object

layer_];
player_.shouldAutoplay = NO;
player_.repeatMode = YES;
player_.view.frame = CGRectMake(10, 10, 300, 300);
[self.view addSubview

layer_.view];
[player_ play];
The problem is: I can get data from the content(NSData),which means the server side is ok. But I don't know how to extract the data from NSData into NSString and then into NSURL so that eventually it could be used by MPMoviePlayerController.
Any help would be appreciated.
Thank you very much in advance!