Home Jsp Implementing JSP and embedding Windows Media Player(wmp)
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Implementing JSP and embedding Windows Media Player(wmp)

Advertisement
Embedding WMP (Windows Media Player) means that you have to attach an external component in your page so that you can play the audio and video files in your JSP page by giving the source path.

Implementing JSP and embedding Windows Media Player(wmp)

        

Example code for implementing JSP and also embedding wmp in JSP page

Embedding WMP (Windows Media Player) means that you have to attach an external component in your page so that you can play the audio and video files in your JSP page by giving the source path. This will make your JSP page interactive.

Before starting, you have to download Windows Media Player. You can download WMP by the following URL http://www.microsoft.com/windows/windowsmedia/player/download

This example will illustrate you how you can embed Windows Media Player in a JSP page. To embed windows media player in your JSP page Object class ID is required and for Windows Media Player 7, 9, 10 and 11, it is CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6.
For embedding this into the "Object" tag we have to insert following lines into our code:

  <embed width="356" height="300"></embed>

Some parameters for media player are as follows:

  • URL: is url of the media file which is to be run on that JSP page
  • AutoStart: is attribute which specifies or retrieves a value indicating whether the current media item begins playing automatically
  • Enabled: specifies whether the Windows Media Player control is enabled or not
  • PlayCount: specifies the number of times a media item will play.
  • Volume: "0" shows no volume and "100" for full volume.
  • Mute: true, if player to be muted.
  • ShowControls: will display all necessary components of media player
  • ShowStatusBar: will display status bar if value is set to "True"

Full code for "wmp.jsp" is given as below:

<%@ page language="java" import="java.io.*" %>
<html>
<head>
<title>Embedding Windows Media Player in JSP</title>
</head>
<body>
<OBJECT id="VIDEO" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" 
width="320" height="240">

<PARAM NAME="URL" VALUE="supman.mpg">

<PARAM NAME="enabled" VALUE="True">

<PARAM NAME="AutoStart" VALUE="False">

<PARAM name="PlayCount" VALUE="3">

<PARAM name="Volume" VALUE="50">

<PARAM NAME="balance" VALUE="0">

<PARAM NAME="Rate" VALUE="1.0">

<PARAM NAME="Mute" VALUE="False">

<PARAM NAME="fullScreen" VALUE="False">

<PARAM name="uiMode" VALUE="full">

</OBJECT>
</body>
</html>

To run this example you have to follow these steps:

  • Firstly download Windows media player 7 and above.
  • Install Windows Media Player.
  • Create and Save wmp.jsp
  • Put supman.mpg or any media file in "JSPMultipleForms"( in our example)
  • Start Tomcat Web Server and type the following URL in address bar "http://localhost:8080/JSPMultipleForms/wmp.jsp"

Output:

By clicking on Play, media file will open

Download Source code

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 4, 2008

Ask Questions?    Discuss: Implementing JSP and embedding Windows Media Player(wmp)   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
gaurav
April 20, 2011
jsp

in param how to use dynamic path for video bcz,we can't use jsp in <object></object>
DMCA.com