Adding Audio and Video Files to Your Site

You put both audio and video files on your Web page in the same way — or ways, rather. The simplest way to do it is the same way you connect any file to a Web page. Just put in a link for visitors to click, something like this one:

<a href="videofile.mpg">Click here to see the                  
						
							vacation video.</a>                                         

Depending upon a particular visitor’s system and configuration, the link to the video or sound file will cause different responses when clicked. It may work right in the browser. It may have to launch an external application to play the file. It may prompt the visitor to download the file. And so on. The one thing that won’t happen is that the file will be a seamless part of your Web page.

If you’d like to make it so, you need to use the EMBED element. Here’s the basic setup:

<embed src="musicfile.mid" width="300" height="100">           
						</embed>                                                       

You may want to pay attention to a few other attributes besides width and height. The most important of these is autostart, which, just like it sounds, starts the music or video playing automatically. Just alter the code so it reads like this:

<embed src="musicfile.mid" width="300" height="100"            
						   autostart="true">                                           
						</embed>                                                       

The other useful attribute is loop, which sets whether the file will play more than once and, if so, how many times. To set it to play over and over again forever, just do this:

<embed src="musicfile.mid" width="300" height="100"            
						   autostart="true" loop="true">                               
						</embed>                                                       

To specify how ...

Get Building a Web Site For Dummies®, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.