• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Video Player

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to create my own site like youtube.

I have so many videos stored in exteranl HDD.

I don't how to start or what to do.

In HTML%, there is a video and we can provide source ="" ...

I want my servlet to read video file from storage location... so I can use tht url as src for video tag

Please show me direction what to do


Thanks
Abhi
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just set the proper content type and content length, and copy the contents of the file to the servlet's output stream.
 
Abhishek Shrma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rob,

Thank you for your reply. I did that already. May be I didn't explained my question properly.
What you said will work but only once, I mean you won't have to seek video, because it's depend on outputstream.

Do I need any video server or something, for example

I have
<video><source src="http://video.abhishek.com?id=1&encrypt=........"></source></video>

so this will hit my server and grab video to play. All videos are stored in mnt drive (not in same webserver).

Please guide me thanks
 
Marshal
Posts: 28293
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You said you wanted your site to be "like youtube". Okay: what does YouTube do? You can see their HTML, can't you?
 
Abhishek Shrma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Paul,

May be I didn't clear my requirements properly . Here what I want.

I have like TB's of video stored in mnt drive.
Each video has it name stored in DB. So my video list page shows all videos link like <a href="video.abhishek.com?id=<id>&encrypt=<key>>${video.VideoName}</a>
Now when I'll click any link it will go to Servlet which will pull video from mnt drive and and dispatch to a jsp page so that I can use this

<video><source src="video.abhishek.com/samplevideo.mp4"></video>

I can able to do this if my video is stored on web directory but as I mentioned all my videos are in a separate drive

I dont' know if I want youtube of any thing, but wat I mentioned is my requirement.

Please Help
 
Paul Clapham
Marshal
Posts: 28293
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. So like Rob already said, have your servlet copy the contents of the video to its output stream. I don't see why it makes any difference where the video is actually stored as long as the servlet code knows where it is.
 
Abhishek Shrma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String videoUrl = "../videos/"+"abhishek"+"/"+"videos"+"/"+batchName+"/"+videoName+"/200";
HTML video = new HTML("<video id=\"my_video_1\" class=\"video-js vjs-default-skin\" controls preload=\"auto\" width=\"640\" height=\"264\" data-setup=\"{}\">"+
"<source src="+videoUrl+" type='video/mp4'></video>");


here videos is my servlet


String videoPath= "C:/mnt/bigvol/WebImages/videos/2011/clips/";
String videoName= "L_00010.mp4";
ServletContext application= getServletConfig().getServletContext();
File file = new File(videoPath,videoName);


String contentType = getServletContext().getMimeType(file.getName());
response.setBufferSize(DEFAULT_BUFFER_SIZE);
response.setHeader("Content-Type", "video/mp4");
response.setHeader("Content-Length", Long.toString(file.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");

// Prepare streams.
BufferedInputStream input = null;
ServletOutputStream outputStream = response.getOutputStream();
BufferedOutputStream output = null;
try {
// Open streams.
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
output = new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);

// Write file contents to response.

int length;
while ((length = input.read(buffer,0,4096)) != -1) {
outputStream.write(buffer, 0, length);
}
} finally {
// Gently close streams.
// close(output);
// close(input);
try{
if(input != null)
input.close();
}catch (Exception e) {
// TODO: handle exception
}
if(outputStream != null)
outputStream.flush();
}

I cannot seek forward or backward and once played I cant play again .
I can setup a new server to serve video I read something like HTTP pusedstreaming etc.

Is I am in right direction ??
 
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a link to a tutorial on building a video display portlet for Liferay 5.2. I know you aren't building a portlet, but some of the concepts there may be useful to you.

Blog Page

There's also a downloadable portlet project for Liferay 6.0 where you can actually get the source code for it.

Liferay Download
 
Liar, liar, pants on fire! refreshing plug:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic