json for parsing video for iOS
I have a video file stored in json(in a URL), that requires a jsonp parse request to play, and I need to do this in an iPad app. I am not sure where to start, I know how to parse data with json. But I need to figure out how to parse video and then play it in an app.
Thanks! EDITS:is this what you guys mean:
SBJSON *json = [[SBJSON new] autorelease];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[json objectWithString:res开发者_如何学PythonponseString ]];
//NSArray *luckyNumbers = [json objectWithString:responseString error:&error];
[responseString release];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
//---play partial screen---
player.view.frame = CGRectMake(0, 0, 200, 200);
[self.view addSubview:player.view];
//---play movie---
[player play];
Use any JSON Parser like JSONkit, YAJL, TouchJSON to parse your JSON data for the video URL. Then download that video and write to disk using NSURLConnection delegate methods or you can use ASIHTTP. Then play the downloaded video using MPMoviePlayerController.
use SBJSON Parser
http://code.google.com/p/json-framework/
after fetching the video URL, if the URL is on http live streaming, you dont need to download it explicitly. Just create:
MPMoviePlayerController's objet and use initWithContentURL.
then present it on screen. It will automatically stream the video for you. if the video is not on http live streaming, you should follow what @Nikita have mentioned.
I just had the XNL format changed to store a URL call for the video instead of it being in a JSON file
精彩评论