Multimedia (Multimedia) in JavaScript

The navigator object in JavaScript includes a child object called plugins. This object is an array, with an entry for each plug-in installed in the browser. The navigator.plugins object is only supported by Netscape, Firefox and Mozilla.

The navigator object in JavaScript includes a child object called plugins. This object is an array, with an entry for each plug-in installed in the browser. The navigator.plugins object is only supported by Netscape, Firefox and Mozilla.

For example

Below is an example to illustrate how to list all plug-ins installed in your browser.

 List of Plug-Ins  border = "1" >   Plug-in Name   Filename   Description  language = "JavaScript" type = "text/javascript" > for ( i = 0 ; i < navigator . plugins . length ; i ++) { document . write ( "" ); document . write ( navigator . plugins [ i ]. name ); document . write ( "" ); document . write ( navigator . plugins [ i ]. filename ); document . write ( "" ); document . write ( navigator . plugins [ i ]. description ); document . write ( "" ); } 

Result

Multimedia (Multimedia) in JavaScript Picture 1Multimedia (Multimedia) in JavaScript Picture 1

Check for Plug-Ins

Each plug-in has an entry in that array. Each gateway has the following properties:

name - The name of the plug-in.

filename - An executable file that is downloaded to install the plug-in.

Description - A description of the plug-in, provided by the programmer.

mimeTypes - An array with an input port for each MIME type supported by that plug-in.

You can use these properties in a script to find installed plug-ins, and then use JavaScript, you can play the appropriate multimedia files. You observe the following example:

 Using Plug-Ins  language = "JavaScript" type = "text/javascript" > media = navigator . mimeTypes [ "video/quicktime" ]; if ( media ){ document . write ( "  " ); } else { document . write ( " Multimedia (Multimedia) in JavaScript Picture 2Multimedia (Multimedia) in JavaScript Picture 2 " ); } 

Result

Run the above command to see the result

Note - Here we are using HTML tags to embed multimedia files.

Multimedia control

Together we do a real example that works in most browsers:

 Using Embeded Object  type = "text/javascript" >   id = "demo" name = "demo" src = "http://www.amrood.com/games/kumite.swf" width = "318" height = "300" play = "false" loop = "false" pluginspage = "http://www.macromedia.com/go/getflashplayer" swliveconnect = "true" >  name = "form" id = "form" action = "#" method = "get" >  type = "button" value = "Start" onclick = " play (); " />  type = "button" value = "Stop" onclick = " stop (); " />  type = "button" value = "Rewind" onclick = " rewind (); " /> 

Result

Run the above command to see the result

According to Tutorialspoint

Previous article: Animation in JavaScript

Next article: Debug in JavaScript

4 ★ | 1 Vote