English 中文(简体)
HTML - Embed Multimedia
  • 时间:2024-11-03

HTML - Embed Multimedia


Previous Page Next Page  

Sometimes you need to add music or video into your web page. The easiest way to add video or sound to your web site is to include the special HTML tag called <embed>. This tag causes the browser itself to include controls for the multimedia automatically provided browser supports <embed> tag and given media type.

You can also include a <noembed> tag for the browsers which don t recognize the <embed> tag. You could, for example, use <embed> to display a movie of your choice, and <noembed> to display a single JPG image if browser does not support <embed> tag.

Example

Here is a simple example to play an embedded midi file −

<!DOCTYPE html>
<html>

   <head>
      <title>HTML embed Tag</title>
   </head>
	
   <body>
      <embed src = "/html/yourfile.mid" width = "100%" height = "60" >
         <noembed><img src = "yourimage.gif" alt = "Alternative Media" ></noembed>
      </embed>
   </body>

</html>

The <embed> Tag Attributes

Following is the pst of important attributes which can be used with <embed> tag.

Note −The apgn and autostart attributes deprecated in HTML5. Do not use these attributes.

Sr.No Attribute & Description
1

apgn

Determines how to apgn the object. It can be set to either center, left or right.

2

autostart

This boolean attribute indicates if the media should start automatically. You can set it either true or false.

3

loop

Specifies if the sound should be played continuously (set loop to true), a certain number of times (a positive value) or not at all (false)

4

playcount

Specifies the number of times to play the sound. This is alternate option for loop if you are usiong IE.

5

hidden

Specifies if the multimedia object should be shown on the page. A false value means no and true values means yes.

6

width

Width of the object in pixels

7

height

Height of the object in pixels

8

name

A name used to reference the object.

9

src

URL of the object to be embedded.

10

volume

Controls volume of the sound. Can be from 0 (off) to 100 (full volume).

Supported Video Types

You can use various media types pke Flash movies (.swf), AVI s (.avi), and MOV s (.mov) file types inside embed tag.

    .swf files − are the file types created by Macromedia s Flash program.

    .wmv files − are Microsoft s Window s Media Video file types.

    .mov files − are Apple s Quick Time Movie format.

    .mpeg files − are movie files created by the Moving Pictures Expert Group.

<!DOCTYPE html>
<html>

   <head>
      <title>HTML embed Tag</title>
   </head>

   <body>
      <embed src = "/html/yourfile.swf" width = "200" height = "200" >
         <noembed><img src = "yourimage.gif" alt = "Alternative Media" ></noembed>
      </embed>
   </body>

</html>

This will produce the following result −