News & UpdatesProgrammingWeb programming Store My Projects

HTML Tutorial – 16 – Multimedia

The element used for embedding multimedia and applications in HTML is called <object>. It replaces older tags such as <applet> and <embed>. The <object> element enables the inclusion of objects such as images, video, flash, sounds and applications into a webpage.

To include an object one of two attributes are used to specify its location. The data attribute is used to embed data that the browser can display by itself, such as a document or an image. The type attribute is used in combination with the data attribute to identify the data file type.

<object data="pvt.png" type="image/png"></object>

The other attribute for specifying the object’s location is classid. This attribute is used if the object needs to execute an external program, such as a media player, active-x control or Java applet. Codetype is typically used together with this attribute to identify the content type of the expected data. If codetype is omitted, the type attribute will be used instead.

The codebase attribute provides an alternative base URL from which the browser will retrieve the object. The value of this attribute is a link pointing to a directory containing the object referenced by the classid attribute. The standby attribute can be used to display a message while the browser is downloading the object data. Some other attributes are available that are the same as for the image tag. Most importantly, the height and width attributes, which control the size of the object.

The <param> tag is used to specify an input parameter to the object. This tag may only appear inside an object element and has no content or end tag. It required two attributes: either name and value or id and value. Together, they define a name/value pair that is passed to the object.

Below is an example of how the object element can be used to show a video file.

<object id       = "mediaPlayer" 
        width    = "640" 
        height   = "545"
        classid  = "CLSID:6BF52A52-394A-11d3-
        codebase = "
        standby  = "Loading Microsoft Windows 
                    Media Player components..." 
        type     = "application/x-oleobject" VIEWASTEXT>
           <param name="url"       value="MyVideo.avi">
           <param name="autoStart" value="true">
           <param name="wmode"     value="transparent">
           <param name="uiMode"    value="full">
           <param name="loop"      value="false">            
Recommended additional reading:
Sams - Teach Yourself HTML and CSS in 24 Hours