用于解析 iOS 视频的 json
我有一个存储在 json 中的视频文件(在 URL 中),需要 jsonp 解析请求才能播放,并且我需要在 iPad 应用程序中执行此操作。我不知道从哪里开始,我知道如何用 json 解析数据。但我需要弄清楚如何解析视频然后在应用程序中播放它。
谢谢! 编辑:这就是你们的意思吗:
SBJSON *json = [[SBJSON new] autorelease];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[json objectWithString:responseString ]];
//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];
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:responseString ]];
//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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用任何 JSON 解析器(例如 JSONkit、YAJL、TouchJSON)来解析视频 URL 的 JSON 数据。然后下载该视频并使用 NSURLConnection 委托方法写入磁盘,或者您可以使用 ASIHTTP。然后使用 MPMoviePlayerController 播放下载的视频。
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.
使用 SBJSON 解析器
http://code.google.com/p/json-framework/
获取视频URL后,如果该URL是http直播的,则无需显式下载。只需创建:
MPMoviePlayerController 的对象并使用 initWithContentURL。
然后将其呈现在屏幕上。它会自动为您传输视频。
如果视频不在 http 直播中,您应该遵循 @Nikita 提到的内容。
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.
我刚刚更改了 XNL 格式以存储视频的 URL 调用,而不是将其存储在 JSON 文件中
I just had the XNL format changed to store a URL call for the video instead of it being in a JSON file