3

I want to load a video file from my local directory ("E:\video") and display it using JW Player in my Spring MVC web application. The JW Player does not play video files, it simply displays the loading icon.

My front-end player setup:

$(function() {
  var vplayer = jwplayer("playerDiv").setup({
    'flashplayer': '../../player.swf',
    'id': 'playerID',
    'width': '440',
    'height': '380',
    'mute': false,
    'volume': '100',
    'file': 'spring/loadVideoFile',
    'controlbar': 'bottom',
    'provider': 'video'
  });
  vplayer.play();
});

My request handler:

@RequestMapping(value = "/loadVideoFile", method = RequestMethod.GET)
@ResponseBody public void loadVideoFile(HttpServletResponse response) {
    try {           
        String filePath = "E://video//26.mov";        
        int fileSize = (int) new File(filePath).length();
        response.setContentLength(fileSize);
        response.setContentType("video/quicktime");
        FileInputStream inputStream = new FileInputStream(filePath);
        ServletOutputStream outputStream = response.getOutputStream();
        int value = IOUtils.copy(inputStream, outputStream);
        System.out.println("File Size :: "+fileSize);
        System.out.println("Copied Bytes :: "+value);
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(outputStream);
        response.setStatus(HttpServletResponse.SC_OK);
    } catch (java.io.FileNotFoundException e) {         
        response.setStatus(HttpStatus.NOT_FOUND.value());
    } catch (Exception e) {         
        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
    }
}

How the JW Player appears:

enter image description here

approxiblue
  • 6,982
  • 16
  • 51
  • 59
SENTHIL SARAVANAN
  • 719
  • 1
  • 12
  • 28
  • Is it possible to provide a link to where this is running? – emaxsaun Apr 25 '14 at 20:37
  • Thanks Ethan for your replay. Now i deployed this code in my linux server. Now this code work perfectly, but i'm unable to play video's in iPhone / iPad. Jwplayer displayed like "the video could not be loaded because the format is not supported", please guide me how to play videos in iPhone. My app url is http://216.224.166.63:8080/iPhonePlayer/ – SENTHIL SARAVANAN Apr 26 '14 at 06:58
  • FYI i'm using mediaplayer-5.10 – SENTHIL SARAVANAN Apr 26 '14 at 10:52
  • What type of a file is this? - loadVideoFile.htm – emaxsaun Apr 28 '14 at 03:08
  • i use .mov files, Please refer my post "E://video//26.mov" – SENTHIL SARAVANAN Apr 28 '14 at 04:36
  • I would check how the file was encoded. Try to test with this one - http://www.bogotobogo.com/VideoStreaming/Files/nginxSmoothStream/BigBuckBunny/bunny.mov – emaxsaun Apr 28 '14 at 13:49
  • Dear Ethan, Thanks for your support. Now i find out actual problem. Actual problem is my java code is not stream data as expected manner. Now i use third party media servers and now my problem was solved. thanks a lot for your help – SENTHIL SARAVANAN May 02 '14 at 07:13
  • Np, glad you got it working. – emaxsaun May 02 '14 at 15:23

0 Answers0