How can I link to an .mp4 video in my site?

novellino picture novellino · Aug 24, 2011 · Viewed 27.6k times · Source

I have a web site and I want to link a button to a video. So whenever someone clicks the "video" buttons let's say, I want to open the video.mp4 in a new browser. What I do is:

<a href="videos/engine/swf/player.swf?url=../../data/video.mp4&volume=100" target="_blank"><div>...</div></a>

The video is quite big (190MB) so the code above is not working. I start listening to the sound but cannot see the image.

Does anyone know how to do it? Or any simple way to just open this video as a link?

Answer

No_or_yes picture No_or_yes · Aug 24, 2011

You could use HTML5 tag don't forget that MP4 is only supported by IE 9+, Chrome 5+ and Safari 3+. You should at least convert your file to WebM or Ogg to make it compatible with all recent browsers. To do so you would need a new page (where the link goes) and in this page have this code:

<video width="320" height="240" controls="controls">
  <source src="movie.ogg" type="video/ogg" />
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.webm" type="video/webm" />
  Your browser does not support the video tag.
  /* instead of the last line you could also add the flash player*/
</video>

The browser will automatically select the first known format and play it. (source: w3Schools.com)

Hope this helps!