Now that we have set up the basic video code, it is time to try playing the video—in some circumstances, you may find that browsers will not play videos correctly if it can't determine the mime type to use. In this task, we implement an easy change to rectify this and allow videos to play correctly.
Multi-Purpose Mail Extension (MIME) types are made up of two parts—a type and a subtype—and are means to help define file types so that a client PC can correctly interpret how to treat a file received from a server via the Internet. For example, the HTML5 video formats used in this book have the type of video, but the subtypes could be .ogg
, .mp4
, or .webm
.
.htaccess
into the root folder of your website.AddType video/ogg .ogv AddType video/mp4 .mp4 AddType video/webm .webm
In most instances, browsers will usually play the right video. However, the HTTP protocol doesn't know the concept of file extensions—this means you cannot rely on a browser being able to play the right video all of the time. To get around this, we add in this small configuration change, so that the browser is able to correctly determine the file format from the extension and play the video.