title: iOS streaming video from Spring MVC
body: <p>I'm writing both server and client side application that should stream video from server written using Spring MVC to iOS application that plays it using MPMoviePlayerViewController.</p>
  
  <p>Obstacle is: MPMoviePlayerViewController always shows _itemFailedToPlayToEnd error. I've tried many different solutions but still no success. If I download video first and then play it from filesystem - everything goes fine. </p>
  
  <p>This is my iOS code:</p>
  
  <pre><code>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];
  </code></pre>
  
  <p>And here goes my Java code:</p>
  
  <pre><code>OutputStream out = httpServletResponse.getOutputStream();
  httpServletResponse.setContentType(file.getContentType());
  InputStream inputStream = new FileInputStream(file.getFilePath());
  IOUtils.copy(inputStream, out);
  out.flush();
  </code></pre>
  
  <p>What I do wrong? </p>