How do you stream M4V video on the web without using Flash?

Alex picture Alex · Mar 17, 2010 · Viewed 9.9k times · Source

I'm building a web site that needs to stream video and be friendly for handheld devices (especially the iPhone). Some handhelds don't support Flash so I'm avoiding the use of a Flash player. How does Youtube stream its videos so that they play on both desktops and iPhones? I'm looking for a player, or multiple players, which can be somehow activated based on the user's device.

Your help and guidance are much appreciated. Thanks.

Answer

MrMage picture MrMage · Mar 17, 2010

The YouTube website and others use the HTML5 video tag for streaming playback on iPhones. It works like this:

<video  width="480" height="360" controls>
    <source src="test.mp4" type="video/mp4" />
    <source src="test.ogv" type="video/ogg" />
</video>

In Safari (Desktop as well as mobile) and Chrome, the h264-compressed test.mp4 file will be played. Firefox will play back test.ogv. For other videos, you should still have a flash video player as fallback. You can have all the format choosing and flash fallback done automatically using HTML5Media. You might also check out SublimeVideo, which provides video player controls for the <video> tag.