Online Documentation Server
 ÏÎÈÑÊ
ods.com.ua Web
 ÊÀÒÅÃÎÐÈÈ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ÏÎÄÏÈÑÊÀ

 Î ÊÎÏÈÐÀÉÒÀÕ
Âñÿ ïðåäîñòàâëåííàÿ íà ýòîì ñåðâåðå èíôîðìàöèÿ ñîáðàíà íàìè èç ðàçíûõ èñòî÷íèêîâ. Åñëè Âàì êàæåòñÿ, ÷òî ïóáëèêàöèÿ êàêèõ-òî äîêóìåíòîâ íàðóøàåò ÷üè-ëèáî àâòîðñêèå ïðàâà, ñîîáùèòå íàì îá ýòîì.




Previous Table of Contents Next

Properties of the mimeTypes Object

A mimeTypes object, as found in the mimeTypes array (as an element), features the following properties:

  • type—the name of the MIME type, such as "video/mpeg" or "audio/x-wav". This property is obviously a string.
  • description—a description of the MIME type, such as "JPEG Image".
  • enabledPlugin—a reference to the plugins object that handles the MIME type.
  • suffixes—a string listing possible filename extensions (suffixes) for the MIME type. This property is a string consisting of any valid suffix, typically three letters long, separated by commas.
  • length—the number of elements in the array.

Example 30-1 shows a list of the MIME types supported by the browser, including all three string properties of each mimeTypes object.

<HTML>
<HEAD>
<TITLE>Supported MIME types</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--

// notice that you do not have to issue </TH> and </TD> tags!
document.write("<TABLE BORDER=1><TR
VALIGN=TOP>" +
"<TH ALIGN=left><I>i</I>" +
"<TH ALIGN=left><I>type</I>" +
"<TH ALIGN=left><I>description</I>" +
"<TH ALIGN=left><I>suffixes</I></TR>")
for (var I = 0; i < navigator.mimeTypes.length; ++i) {
 document.writeln("<TR VALIGN=TOP><TD>" +
 i +
 "<TD>" +
 navigator.mimeTypes[i].type +
 "<TD>" +
 navigator.mimeTypes[i].description +
 "<TD>" +
 navigator.mimeTypes[i].suffixes +
 "</TR>")
}

document.writeln("</TABLE>")

// -->
</SCRIPT>
</BODY>
</HTML>

Example 30-1. We use tables to organize the list of supported MIME types.


Figure 30-1.  The scrollbar’s position indicates that the number of MIME types supported by our browser is much more than 10.

Try loading Example 30-1 in your browser. You should see a fairly long list of MIME types. Figure 30-1 shows the beginning of the list as it appeared on our computer.

Notice that in Example 30-1 we referred to elements of the mimeTypes array by indexes. You can also use the MIME type’s name as shown earlier in this chapter. Here are a few examples:

navigator.mimeTypes["image/jpeg"].type
navigator.mimeTypes["image/jpeg"].description
navigator.mimeTypes["image/jpeg"].suffixes

Properties of the plugins Object

The plugins object features the following properties:

  • name—the name of the plug-in
  • filename—the name of the plug-in file on disk.
  • description—a description supplied by the plug-in itself.
  • length—the number of elements in the array.
  • […]—array of mimeTypes objects, indexed by number or type, that the plug-in can handle.

The following statement, for example, assigns shorthand variables for the predefined Shockwave properties:

var myPlugin = navigator.plugins["Shockwave"].name
var myPluginFile = navigator.plugins["Shockwave"].filename
var myPluginDesc = navigator.plugins["Shockwave"].description

Example 30-2 lists the installed plug-ins, including each plug-in’s name, filename, description, and MIME types that it handles.

<HTML>
<HEAD>
<TITLE>Installed plug-ins</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
// notice that you do not have to issue </TH> and </TD> tags!
document.write("<TABLE BORDER=1>")
for (i = 0; i < navigator.plugins.length; ++i) {
document.writeln("<TR><TD><FONT SIZE=2>"+
 "<U><B>" + navigator.plugins[i].name +
 "</B></U><BR>" +
 "<U>Filename:</U> " + navigator.plugins[i].filename +
 "<BR>" +
 "<U>Description:</U> " + navigator.plugins[i].description +
 "<BR>" +
 "<U>MIME types:</U> ")
 for (var j = 0; j < navigator.plugins[i].length; ++j) {
  document.write(navigator.plugins[i][j].type + "; ")
 }
document.write("</FONT></TD></TR>")
}
document.write("</TABLE>")
// -->
</SCRIPT>
</BODY>
</HTML>

Example 30-2. We use the navigator.plugins to list the installed plug-ins and their properties.


Figure 30-2.  The plug-ins installed on our computer.

Figure 30-2 shows the exact output of Example 30-2 on our PC.

The following statement assigns the string "LiveAudio" to a variable:

var audioPlugin =
 navigator.mimeTypes["audio/basic"].enabledPlugin.name

The name property belongs to a plugins object, because navigator.mimeTypes["audio/basic"].enabledPlugin is equivalent to navigator.plugins["LiveAudio"].

LiveAudio and LiveVideo

LiveAudio and LiveVideo are plug-ins that come built into Netscape Navigator 3.0x and above. LiveAudio enables you to embed audio in a Web page, whereas LiveVideo supports various video formats. Since both LiveAudio and LiveVideo are plug-ins, you include them in an HTML document via the standard <EMBED> tag.

LiveAudio

LiveAudio plays audio files in WAV, AIFF, AU, and MIDI formats. Audio controls appear according to the size specified in the WIDTH and HEIGHT parameters in the <EMBED> tag. You can create an audio console with any of the following views:

  • console—consisting of a Play, Pause, Stop, and volume control lever. This is the most complete suite of controls.
  • smallConsole—consisting of a Play, Stop, and volume control lever. The buttons in this view are somewhat smaller than those in a console.
  • playButton—a button that starts the sound playing.
  • pauseButton—a button that pauses (without unloading) the sound while it is playing.
  • stopButton—a button that ends the playing of sound and unloads it.
  • volumeLever—a lever that adjusts the volume level for playback of the sound (and adjusts the system’s volume level).
Previous Table of Contents Next


With any suggestions or questions please feel free to contact us