DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chara has posted 50 posts at DZone. View Full User Profile

Media Code in HTML5

02.13.2013
| 3817 views |
  • submit to reddit
<!-- source: http://www.apphp.com/index.php?snippet=html-5-media-code -->
<video poster="images/preview.png" width="800" height="600" controls="controls" preload="none"> 
  <source src="media/my_video.mp4" type="video/mp4"></source> 
  <source src="media/my_video.webm" type="video/webm"></source> 
  <source src="media/my_video.ogg" type="video/ogg"></source>
</video>
<audio controls="controls" preload="none">
  <source src="audio/my_music.ogg" type="audio/ogg">
  <source src="audio/my_music.mp3" type="audio/mpeg">
</audio>

This example is a basic design structure for loading multiple video and audio formats for universal work of media content on your page.