How to embed HTML5 video with fallback

1 min read 209 words

A common question with the rise of HTML5 becoming more and more common and the whole iGeneration (iPhones/iPads/iEtc) is “how can I embed a video on my site without using a flash player?”. If you’re working with HTML, you might also be interested in how to correctly form HTML and how to place HTML div on top of Flash .

An option that really does work quite well is to use the JWPlayer and set it up to use HTML5.

The benefit of going this route is you can also tell it to have a fallback to flash if the browser is not HTML5 compatible, or even fall all the way back to downloading the video if all else fails.

Firstly, you will want to download the JWPlayer here.

Then set it up on your page(s).

<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>

Then add a div container for the player to embed itself in.

<div id="myMediaPlayer"></div>

Then you will setup the actual code to make things happen!

<script type="text/javascript">
  jwplayer("myMediaPlayer").setup({
    "id": "playerID",
    "width": "480",
    "height": "270",
    "file": "/videos/someVideo.mp4",
    "image": "/thumbs/someVideoThumb.jpg",
    "modes": [
        {type: "html5"},
        {type: "flash", src: "player.swf"},
        {type: "download"}
    ]
  });
</script>

If you are looking for all the attributes you can take a sneak peak no the official setup wizard.

Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags