wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes video playing/streaming Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "video playing/streaming" Watch "video playing/streaming" New topic
Author

video playing/streaming

Singh Kuldeep
Greenhorn

Joined: Jul 18, 2012
Posts: 19
Hi, I want to add video playing support from database to my website using jsp. Can some body help me?
Thank You.....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

ShowSomeEffort. What have you tried so far? What problems are you having?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Singh Kuldeep
Greenhorn

Joined: Jul 18, 2012
Posts: 19
Bear Bibeault wrote:ShowSomeEffort. What have you tried so far? What problems are you having?


Hi Bibeaul! thanks for your reply.
Actually I upload a video on server and kept the reference in database by name. Now i want to play this video on client(browser ) with out downloading.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

Impossible. To play the video, the data must be sent to the client.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10242
    
168

Singh Kuldeep wrote:
Actually I upload a video on server and kept the reference in database by name. Now i want to play this video on client(browser ) with out downloading.


You have to explain what exactly you mean by "without downloading"? Do you mean, when the video is requested by the client, you don't want a "save as" window to pop-up and instead it should just start playing in the client browser?

[My Blog] [JavaRanch Journal]
Singh Kuldeep
Greenhorn

Joined: Jul 18, 2012
Posts: 19
Jaikiran Pai wrote:
Singh Kuldeep wrote:
Actually I upload a video on server and kept the reference in database by name. Now i want to play this video on client(browser ) with out downloading.


You have to explain what exactly you mean by "without downloading"? Do you mean, when the video is requested by the client, you don't want a "save as" window to pop-up and instead it should just start playing in the client browser?


yes.... exactly. I don't want client to save as option. it should start playing in browser....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

You still haven't shown us the code.
Singh Kuldeep
Greenhorn

Joined: Jul 18, 2012
Posts: 19
Bear Bibeault wrote:You still haven't shown us the code.


<%

String filename = "C:\\uploaded-download\\anjane.mov"; //my own filename
//you can write http://localhost
//String filepath = "C:/"; //located on Local C harddisk

BufferedInputStream buf = null;

try {


File myfile = new File( filename);

//set response headers
response.setContentType("application"); //I want to play a video file

response.addHeader(
"Content-Disposition", "attachment; filename=" + filename);

response.setContentLength((int) myfile.length());

FileInputStream input = new FileInputStream(myfile);
buf = new BufferedInputStream(input);
int readBytes = 0;

//read from the file; write to the ServletOutputStream
while ((readBytes = buf.read()) != -1) {
out.write(readBytes);
}

} catch (IOException ioe) {
} finally {


}

%>


Hi Bear Bibeault, Please check this.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

You're trying to stream it from a JSP?

Step 1: Move the code out of a JSP and into a servlet. JSP is a completely unsuitable technology for this.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: video playing/streaming