Read quicktime movie from servlet in a webpage?

Posted by khue on Stack Overflow See other posts from Stack Overflow or by khue
Published on 2010-05-31T06:04:38Z Indexed on 2010/06/01 12:33 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

Hi, I have a servlet that construct response to a media file request by reading the file from server:

 File uploadFile = new File("C:\\TEMP\\movie.mov");
 FileInputStream in = new FileInputStream(uploadFile);

Then write that stream to the response stream. My question is how do I play the media file in the webpage using embed or object tag to read the media stream from the response?

Here is my code in the servlet:

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.getParameter("location"); 
    uploadFile(response); 
}

private void uploadFile(HttpServletResponse response) {
    File transferFile = new File("C:/TEMP/captured.mov"); 
    FileInputStream in = null;

    try {
        in = new FileInputStream(transferFile);
    } catch (FileNotFoundException e) {
        System.out.println("File not found"); 
    }

    try {
        System.out.println("in byes i s" + in.available());
    } catch (IOException e) {
    }

    DataOutputStream responseStream = null;

    try {
        responseStream = new DataOutputStream(response.getOutputStream());
    } catch (IOException e) {
        System.out.println("Io exception"); 
    }

    try {
        Util.copyStream(in, responseStream);
    } catch (CopyStreamException e) {
        System.out.println("copy Stream exception"); 
    }

    try {
        responseStream.flush();
    } catch (IOException e) {
    }

    try {
        responseStream.close();
    } catch (IOException e) {
    }
}

And here is html page as Ryan suggested:

<embed SRC="http://localhost:7101/movies/transferservlet" 
    WIDTH=100 HEIGHT=196 AUTOPLAY=true CONTROLLER=true LOOP=false 
    PLUGINSPAGE="http://www.apple.com/quicktime/">

Any ideas?

© Stack Overflow or respective owner

Related posts about java

Related posts about html