Java 来自Spring MVC的iOS流媒体视频
我正在编写服务器端和客户端应用程序,它们应该将使用SpringMVC编写的服务器上的视频流传输到使用MPMoviePlayerViewController播放视频的iOS应用程序 障碍是:MPMoviePlayerViewController总是显示_itemsfailedtoplaytoEnd错误。我尝试了许多不同的解决方案,但仍然没有成功。如果我先下载视频,然后从文件系统播放,一切都会好起来 这是我的iOS代码:Java 来自Spring MVC的iOS流媒体视频,java,ios,spring,cocoa-touch,spring-mvc,Java,Ios,Spring,Cocoa Touch,Spring Mvc,我正在编写服务器端和客户端应用程序,它们应该将使用SpringMVC编写的服务器上的视频流传输到使用MPMoviePlayerViewController播放视频的iOS应用程序 障碍是:MPMoviePlayerViewController总是显示_itemsfailedtoplaytoEnd错误。我尝试了许多不同的解决方案,但仍然没有成功。如果我先下载视频,然后从文件系统播放,一切都会好起来 这是我的iOS代码: NSURL *movieURL = [NSURL URLWithString:
NSURL *movieURL = [NSURL URLWithString:@"http://myhost.com:8080/application/files/1];
self.moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self.moviePlayerController.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[self.moviePlayerController.moviePlayer setShouldAutoplay:YES];
[self.moviePlayerController.moviePlayer setFullscreen:NO animated:YES];
[self.moviePlayerController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.moviePlayerController.moviePlayer setScalingMode:MPMovieScalingModeNone];
self.moviePlayerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[self presentMoviePlayerViewControllerAnimated:self.moviePlayerController];
下面是我的Java代码:
OutputStream out = httpServletResponse.getOutputStream();
httpServletResponse.setContentType(file.getContentType());
InputStream inputStream = new FileInputStream(file.getFilePath());
IOUtils.copy(inputStream, out);
out.flush();
我做错了什么 将浏览器指向URL时会发生什么情况?内容类型设置是否正确?使用MPMoviePlayerViewController的要求是什么?它是处理从看起来像基本文件下载的流式传输,还是您必须做一些不同/特殊的事情?在浏览器中,它只是下载一个文件。我尝试了不同的内容类型,因为应用程序的结果仍然是一样的,但浏览器会将其行为从下载文件更改为在其中启动quicktime player。据我所知,MPMoviePlayerViewController可以处理八位字节流或视频/*内容类型取决于我尝试过的所有设置。是的,我想用渐进播放的方式下载基本的部分文件。将客户端中的“Accepts”头更改为
*/*
,看看是否有帮助。我无法更改客户端cos框架中的Accepts头。你能在服务器端打印它们吗?