INSY214 Chapter5
INSY214 Chapter5
CHAPTER 5
LOGO
Contents
2
D. Gichuki
6.1 About Audio and Video Files
3
D. Gichuki
6.2 Linkig to Audio and Video Files
The most basic way to provide audio and video files to your
visitors is to directly link to the related files.
When clicked, the file will open and play in a separeate
window.
Just same as with other links, be sure to upload the video or
audio file to your Web server to avoid broken links.
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
4
D. Gichuki
6.3 Adding Audio
5
D. Gichuki
6.3 Adding Audio
6
D. Gichuki
6.3 Adding Audio
Attribute Description
autoplay This Boolean attribute if specified, the audio will
automatically begin to play back as soon as it can
do so without stopping to finish loading the data.
muted Specifies that the audio output should be muted
7
D. Gichuki
6.3 Adding Audio
Attribute Description
loop This Boolean attribute if specified, will allow audio
automatically seek back to the start after reaching
at the end.
preload This attribute specifies that the audio will be loaded
at page load, and ready to run. Ignored if autoplay
is present.
src The URL of the audio to embed. This is optional;
you may instead use the <source> element within
the audio block to specify the audio to embed.
8
D. Gichuki
6.3 Adding Audio
Example
<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="bird.ogg" type="audio/ogg">
<source src="bird.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body> <audio src="/music/myaudio.ogg" autoplay></audio>
</html>
Result
Displays your audio file with controls for user to play the file.
The text will only be displayed in browsers that do not support the
<audio> element.
9
D. Gichuki
6.4 Adding Video
10
D. Gichuki
6.4 Adding Video
Attribute Description
controls Specifies that video controls should be displayed (such as a
play/pause button etc).
preload Specifies that the video will be loaded at page load, and ready to
run. Ignored if autoplay is present.
src The URL of the video to embed. This is optional; you may instead
use the <source> element within the video block to specify the
video to embed.
poster This is a URL of an image to show until the user plays or seeks.
autoplay Specifies that the video will start playing as soon as it is ready.
muted Specifies that the audio output of the video should be muted.
11
D. Gichuki
6.4 Adding Video
Example
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
<video src="/myvideo.mp4"></video>
</body>
</html>
Result
Displays the video, with play, pause and volume controls, in a
space 320 pixels wide and 240 pixels high. If the browser does not
support the video, the text that you entered will be displayed:
Your browser does not support the video tag.
12
D. Gichuki
6.5 HTML <embed> Tag
Example
<!DOCTYPE html>
<html>
<body>
<embed src="helloworld.swf">
<embed src="flower.jpeg">
</body>
</html>
14
D. Gichuki
6.6 Using Youtube to Display Video
15
D. Gichuki
6.6 Using Youtube to Display Video
Example
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Result
Displays the video in an iframe 600 pixels wide by 400 pixels high.
16
D. Gichuki