1

Here I got a URL. I can't provide the whole string but part of it is "http://*/video.mjpg". When I open it with browser(firefox), it shows the video. When I analyze the package using Fiddler, it shows this:

HTTP/1.1 200 OK

Server:*

Pragma:no-cache

Cache-Control:no-cache

Content-Type:multipart/x-mixed-replace; boundary="myboundary"

I search the Internet and I got the these key word: MIME, dynamic parsing. But I still don't have a clue how to parse it. Hope anyone could help me. How to parse the message in Java and Objective-C to display the video content in Android and iOS?

4

2 回答 2

0

对于 iOS,您可以使用

编辑

NSString *url = @"http://*/video.mjpg";
NSError *error = nil;

videoData = [NSData dataWithContentsOfURL:[NSURL urlWithString:url] options:nil error:&error];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"videoToPlay.mp4"];

[videoData writeToFile:path atomically:YES];
NSURL *moveUrl = [NSURL fileURLWithPath:path];
player = [[MPMoviePlayerController alloc]init];
[player setContentURL:moveUrl];
player.view.frame = viewPlayer.bounds;
[viewPlayer addSubview:player.view];
[player play];

看看这个苹果的样本

安卓版

我不是 Android 开发人员,但我已将此答案 用于我测试的演示。

于 2013-05-14T07:34:45.127 回答
0

对于安卓:

if (the_link_of_the_video_here.startsWith("http://") == false){
the_link_of_the_video_here="http://"+the_link_of_the_video_here;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(the_link_of_the_video_here));
startActivity(intent);

the_link_of_the_video_here 是您从 http 请求中收到的链接

于 2013-05-14T09:09:33.993 回答