Multimedia Unit I
Multimedia Unit I
What is Multimedia?
Multimedia comes in many different formats. It can be almost anything you can hear or see,
like images, music, sound, videos, records, films, animations, and more.
Web pages often contain multimedia elements of different types and formats.
Multimedia Formats
The most common way to discover the type of a file, is to look at the file extension.
Multimedia files have formats and different extensions like: .wav, .mp3, .mp4, .mpg, .wmv,
and .avi.
MPEG .mpg MPEG. Developed by the Moving Pictures Expert Group. The
.mpeg first popular video format on the web. Not supported anymore in
HTML.
MP3 is the best format for compressed recorded music. The term MP3 has become
synonymous with digital music.
MIDI .mid MIDI (Musical Instrument Digital Interface). Main format for all
electronic music devices like synthesizers and PC sound cards. MIDI
.midi files do not contain sound, but digital notes that can be played by
electronics. Plays well on all computers and music hardware, but not in
web browsers.
RealAudio .rm RealAudio. Developed by Real Media to allow streaming of audio with
.ram low bandwidths. Does not play in web browsers.
WMA .wma WMA (Windows Media Audio). Developed by Microsoft. Plays well on
Windows computers, but not in web browsers.
AAC .aac AAC (Advanced Audio Coding). Developed by Apple as the default
format for iTunes. Plays well on Apple computers, but not in web
browsers.
WAV .wav WAV. Developed by IBM and Microsoft. Plays well on Windows,
Macintosh, and Linux operating systems. Supported by HTML.
MP3 .mp3 MP3 files are actually the sound part of MPEG files. MP3 is the most
popular format for music players. Combines good compression (small
files) with high quality. Supported by all browsers.
MP4 .mp4 MP4 is a video format, but can also be used for audio. Supported by all
browsers.
HTML images
The HTML <img> tag is used to embed an image in web pages by linking them. It creates a
placeholder for the image, defined by attributes like src, width, height , and alt , and does not
require a closing tag.
There are two ways to insert the images into a webpage:
By providing a full path or address (URL) to access an internet file.
By providing the file path relative to the location of the current web page file.
Basic example of the <img> Tag;
<!DOCTYPE html>
<html>
<body>
<img src=”path” alt=”GFGC image”/>
</body>
</html>
The <img> tag is used to embed an image into the webpage.
src attribute: specifies the source URL of the image
alt attribute: provides alternative text for the image
Various HTML <img> Tag attributes
Attribute Description
Src specifies the path to the image file
Alt Provides alternate text for the image
Height Specifies the height of the image
Width Specifies the width of the image
Sizes Specifies image sizes for different page layouts
HTML Iframes
An iframe, or Inline Frame, is an HTML element represented by the <iframe> tag. It
functions as ‘window’ on your webpage through which visitors can view and interact with
another webpage from different source.
Iframes are used for various purposes like:
Embedding Multimedia: Easily integrate videos, audio, or animations from
platforms like YouTube, etc.
Include Maps: Embed maps from services like Google Maps directly into your site.
Loading Forms and Widgets: Incorporate forms or widgets from other sources
without writing complex code.
Syntax:
<iframe src=”URL” title=”description”>
</iframe>
The src attribute specifies the URL of the document you want to embed.
Iframes can include videos, maps, or entire web pages from other sources.
Example1 : Basic Iframe Embedding
In this example, an iframe is used to display another webpage within the current webpage.
In this example:
src: Specifies the URL of the page to display within the iframe
width and height: Defines the size of the iframe on your page.
Iframe attributes:
height – sets the height of the <iframe> element
width – sets the width of the <iframe> element
scrolling – controls whether or not the <iframe> should have scrollbars
name- specifies the name of the <iframe> for targeting its content or for referencing it
in JavaScript
scr- specifies the URL of the document to embed in the <iframe>
srcdoc – specifies the HTML content of the page to display in the <iframe>
The <map> tag is used to define an image map. An image map is an image with clickable
areas that link to different destinations or perform specific actions. The <map> tag is used in
combination with the <img> tag is used in combination with the <img> tag and <area> tags
to create these interactive regions. Each <area> tag within a <map> defines a shape(rectangle,
circle, polygon) and specifies the coordinates for the clickable area.
Syntax:
<map name="mapname">
<area shape="rect" coords="x1,y1,x2,y2"
href="link1.html" alt="Rectangle Area">
<area shape="circle" coords="x,y,radius"
href="link2.html" alt="Circle Area">
<area shape="poly" coords="x1,y1,x2,y2,x3,y3,..."
href="link3.html" alt="Polygon Area">
</map>
Where –
<img> Tag: Displays the image and references the <map> using the usemap
attribute.
<map> Tag: Defines the clickable areas within the image.
<area> Tag: Specifies the shape, coordinates, link, and description for each
clickable area.
Example: This example demonstrates a simple image map with rectangular clickable
areas.
<!DOCTYPE html>
<html>
<head>
<title>HTML map Tag</title>
</head>
<body style="text-align: center;">
<p>
Click on Images where the
cursor clickable
</p>
<img src="https://media.geeksforgeeks.org/wp-content/uploads/20190808143838/
logsm.png"
alt="Geeks_logo"
usemap="#gfg">
<map name="gfg">
<area href="https://www.geeksforgeeks.org/"
coords="55,76,129,76,128,126,99,126,100,103,82,104,83,125,54,125,51,104"
shape="poly">
</map>
</body>
</html>
Example2
<html>
<body>
<h1>The map and area elements</h1>
<p>Click on the computer, the phone, or the cup of coffee to go to a new page and read more
about the topic:</p>
<img src="workplace.jpg" alt="Workplace" usemap="#workmap" width="400"
height="379">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
<area shape="circle" coords="337,300,44" alt="Cup of coffee" href="coffee.htm">
</map>
</body>
</html>
Attributes
Event Attributes
Example
<!DOCTYPE html>
<html>
<body>
<h1>The map and area elements</h1>
<p>Click on the sun or on one of the planets to watch it closer:</p>
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
</body>
</html>
To embed audio in HTML, we use the <audio> tag. Before HTML5, audio cannot be added
to web pages in the Internet Explorer era. To play audio, we used web plugins like Flash.
After the release of HTML5, it is possible. This tag supports Chrome, Firefox, Safari,
Opera, and Edge in three audio formats – MP3, WAV, OGG.
Syntax:
<audio>
<source src="file_name" type="audio_file_type">
</audio>
Attributes of <audio> tag
Attribute Value Description
auto
metadata It specifies how the author thinks the audio will be loaded
preload
when the page is ready.
none
Example:
In this example, we will add an audio file to a webpage.
<!DOCTYPE html>
<html>
<body>
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
To embed video in HTML, we use the <video> tag. It contains one or more video sources at
a time using <source> tag. It supports MP4, WebM, and Ogg in all modern browsers.
Syntax
<video>
<source src="file_name" type="video_file_type">
</video>
controls controls It displays video control such as play, pause, and stop.
muted muted When the page is loaded video will be automatically muted.
auto
metadat It specifies how the author thinks the video will be loaded
preload
a when the page is ready.
none
Example:
In this example, we will add a video to our webpage. To add video, we will use the <video>
tag defining source using <source> tag.
<!DOCTYPE html>
<html>
<body>
<video width="400" controls>
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML video.
</video>
<p>
Video courtesy of
<a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.
</p>
</body>
</html>