We've been dying to do something cool in our web application, so let's get to it. Let's start out by including a video on our site in the simplest manner possible, and without any complicated interactions!
First, let's open up our index.html
file located in the video
subdirectory of the Chapter 2
project. If you skipped the first chapter, don't worry about it, the Chapter 2
source files follow along and help keep you going.
Once we have our index.html
file, we want to include the video
element within our content area, right after the <header>
element. This is simple, we can do it like this:
<video src="../assets/testvid.mp4" controls preload></video>
The previous code works similar to an image element. We define a src
attribute that instructs the browser where to find the video, and then we define a controls
and preload
attribute, which directs the browser to display default native controls and to preload the video. Simple, eh?