File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes opening a  video file in a browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "opening a  video file in a browser" Watch "opening a  video file in a browser" New topic
Author

opening a video file in a browser

nalini peddareddy
Greenhorn

Joined: Jul 18, 2005
Posts: 16
Hi,
I have a problem opening a video file in a browser through an application.

Techhologies used are servlets and templates

Here is the flow for ur understanding.

I have a link in a template clicking on which calls a javascript(openWindow)taking the url as parameter)Before opening the file the following process takes place.

Reads the file from the database and stores it in a filestore(some folder in server)

//Write the file from BLOB (taking the file data from database)

and then stores it in filestore by taking fileID and filepath.fileIdentifier is the filename.

File oFile = new File(filePath + "/" + fileIdentifier);
out = new BufferedOutputStream(new FileOutputStream(oFile),
bufferSize);

//create byte buffer and start reading the file
byte[] b = new byte[bufferSize];
int count = in.read(b, 0, bufferSize);
logger.debug("Writing file now");

while (count != -1) {
logger.debug(".");
out.write(b, 0, count);
count = in.read(b, 0, (int) bufferSize);
} // end count!=-1

logger.debug("Complete");
out.flush();
out.close();
out = null;
in.close();
in = null;


After all this process it opens a new window displaying the content of the file

This is all working fine for text files, docs and images but is not the case for opening an audio and video file. For video file ,it opens a new window displaying junk text.


Here is the javascript called on clicking the link in the template.


function openFileinWindow(url, width, menubar){
if(!window.window2){
// has not yet been defined
window2=window.open(url,'new1','menubar=' + menubar + ',toolbar=yes,scrollbars=yes,width=' + width + ',height=450');
// window2=window.open(url);
}
else{
//has been defined
if(!window2.closed){
// still open
window2.close();
}
window2=window.open(url,'new1','menubar=' + menubar + ',toolbar=yes,scrollbars=yes,width=' + width + ',height=450');
}
}

Could you please help me out in this topic?

Thank you
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
Hi,
I am not sure, but worth checking.
From command prompt type the "assoc". This command is intended to Displays or modifies file extension associations.
Look for the your audio and video file associations. If not present use the same to associate to audio or video players. same command can be use to associate. Use command "help assoc" to get more details about the assoc command.

Regards
Arun


Sharing is learning
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Arun is talking about desktop configuration, which certainly matters, but unless your client machine has never been used to view video at all (seems unlikely) I doubt that is the problem. The first thing that occurs to me is that that you haven't shown us any code which sets the content-type for the download -- are you sure you're setting it correctly?


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: opening a video file in a browser