How to Insert video to HTML page.
There are several ways of inserting a video to your HTML page. The <embed>, <frame> and <object> tags were being used for inserting videos into an HTML page.
To insert a video in an HTML page, use the <video> element. It specifies a standard way to embed a video in HTML. Just keep in mind to add height and width to the video. Use the source element to add the source of the video, with the src attribute.
Now To Insert video file to HTML file use the following Code given below
<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
</video>
output :
How it work...
There are several ways of inserting a video to your HTML page. The <embed>, <frame> and <object> tags were being used for inserting videos into an HTML page.
To insert a video in an HTML page, use the <video> element. It specifies a standard way to embed a video in HTML. Just keep in mind to add height and width to the video. Use the source element to add the source of the video, with the src attribute.
Now To Insert video file to HTML file use the following Code given below
<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
</video>
output :
How it work...
The
controls
attribute adds video controls, like play, pause, and volume.
It is a good idea to always include
width
and height
attributes. If height and width are not set, the page might flicker while the video loads.
The
<source>
element allows you to specify alternative video files which the browser may choose from. The browser will use the first recognized format.How To Set Video Auto-play
To set autoplay for the video you just need to add the autoplay attribute for the <video> tag like this:
<video width="320" height="240" controls autoplay>
<source src="video.mp4" type="video/mp4">
</video>
<source src="video.mp4" type="video/mp4">
</video>
Insert Videos from Youtube Using the <iframe> Tag
The easiest way to play videos in HTML, is using YouTube as a source. First, you need to upload the video to YouTube or copy the embed code of an existing video which will be inserted in a <iframe> element in your web page.
To have the embed link of the YouTube video follow these simple steps:
- Open the video on YouTube and click the share button.
- Open the Embed code.
- Copy the Source link.
<iframe width="500" height="320" src="http://www.youtube.com/embed/1cZWo6hiuI"
>
</iframe>
0 comments:
Post a Comment