This Readme describes a Proof of Concept showing how to use Java Server Pages (JSPs) to remote control the PRISMIQ MediaPlayer.

This example builds on a post to the PRISMIQ.org community forums by GassyBadger showing how to set up JSP in the Tomcat server used by PRISMIQ MediaManager, and how to remote control the MediaPlayer. (The original post is here) We thought that this was so cool that we wanted to expand on it a bit and tie it into MediaManager's datafiles.

First, some legalese:

The information provided here is for your own use, and comes with no Warranty or Support. If you damage your MediaManager install, please do not contact Technical Support for help, instead please use the PRISMIQ.org community forums.

The Code provided here is either Copyright PRISMIQ, Inc, and liscenced under the GNU Public License, or Copyright GassyBadger, and licensed as he/she chooses

Ok, that part is always fun - to the example. The example code is available here: http://www.prismiq.org/prismiq/customization/mediaplayer-remote-control.zip

Included in this archive are 3 files: this readme, remotecontrol.jsp, and remotemedia.xsl. remotecontrol.jsp uses the XSL Stylesheet to transform media.xml, which is where MediaManager stores data about your mediafiles. By using the PRISMIQ Media Agent external control interface, you can issue commands over the network to the MediaPlayer and play different songs.

As a prequisite, you might want to read the Media Agent documentation to get a better feel for what you can do, and the flow of controling media. The included file does not handle errors, nor is it a very detailed example - it gives you the basics of controlling the Media Agent from an external source.

The Sample JSP is fairly simple - it merely checks for the presence of an HTTP POST or GET arg named "song" which contains a media ID taken from media.map, and if found, passses that to the play() method, which opens a socket to the Media Agent, and executes the proper commands to play the song (Note: there is no real error handling done). The JSP then uses an XML Transformer to take the contents of media.xml (retrieved from a system URL, see the JSP), and use the stylesheet contained in remotemedia.xsl to format the XML into a list of clickable links.that will reload the current page with the correct song parameter. (The Song title is also passed as a paramter, but it is currently not used).


How to set up this demo:

Before attempting this proceedure, shutdown MediaManager on your computer by right clicking on the MediaManager icon in the System Tray (next to the clock), and picking "Exit".
1) Enable remote control of the PRISMIQ Media Agent (magent)
Follow the instructions to make magent accept remote commands (edit etc/magent.conf).

2) Install the Java Development Kit,version 1.4.1
You can get the JDK from this URL: http://java.sun.com/j2se/1.4.1/download.html
You only need the tools.jar file located in JAVA_HOME/lib. For instance, c:\j2se1.4\lib\tools.jar.
Rename C:\Program Files\PRISMIQ\MediaManager\Tomcat\Tomcat_4-0-3\tools.jar to "original-tool.jar" as a backup.
Copy the tools.jar from the JDK install to C:\Program Files\PRISMIQ\MediaManager\Tomcat\Tomcat_4-0-3.
move "c:\Program Files\PRISMIQ\MediaManager\Tomcat\Tomcat_4-0-3\tools.jar" "c:\Program Files\PRISMIQ\MediaManager\Tomcat\Tomcat_4-0-3\orig-tools.jar"
copy c:\j2se1.4\lib\tools.jar "c:\Program Files\PRISMIQ\MediaManager\Tomcat\Tomcat_4-0-3\"
3) Add the jasper JSP compiler to Tomcat's classpath. (note: A future version of MediaManager will remove the need for this step)
cd "C:\Program Files\PRISMIQ\MediaManager"
jar xf Tomcat/Tomcat_4-0-3/jasper-compiler.jar
jar xf Tomcat/Tomcat_4-0-3/jasper-runtime.jar
4) Add the JSP servlet to the MediaManager's "mserver" webapp
Edit web.xml in C:\Program Files\PRISMIQ\MediaManager\webapps\mserver\WEB-INF , and add the following. Note: you must add the <servlet>....</servlet> section at the end of all of the existing <servlet> tags, and the <servlet-mapping> after the other <servlet-mapping> sections.
<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
</servlet-mapping>
5) Edit the the sample JSP, and place it and the XSL file in the correct place:
notepad remotecontrol.jsp
Look for the lines:
// Set this to the IP address of your MediaPlayer
String mplayerIP = "10.0.0.101";
Make sure to set this address to the address of your MediaPlayer, which can be found by going to "setup", and selecting "System Information".
copy remotecontrol.jsp "C:\Program Files\PRISMIQ\MediaManager\webapps\mserver\"
copy remotemedia.xsl "C:\Program Files\PRISMIQ\MediaManager\webapps\mserver\"
6) Restart Tomcat
Choose Start->Programs->PRISMIQ MediaManager->MediaManager

7) Test your new JSP
Open your web browser to http://localhost:8080/mserver/remotecontrol.jsp. You should see a list of your Audio files, and when you click on a link, the MediaPlayer should start playing the song you clicked on.

Bingo, it should start playing the Media that you selected. If it doesn't, make sure that you have correctly setup the Media Agent, and that the IP address of your MediaPlayer is set correctly in the JSP.

Where to go from here:
Well, the obvious answer is to include support for movies. This will involve setting scaling factors, and performing the dev_open non-audio only. Also, there is no way to stop, go to the next track, deal with playlists, etc. These could all easily be implemented, though. One useful bit of information: playlist.xml contains, well, all of the playlists. Each playlist is a list media IDs, as found in media.xml/media.map. Just like the retrieval of media.xml in the jsp file, you can retrieve playlist.xml via a type argument of "playlist". Hrm, do I see a pattern there? :)

We look forward to seeing what the community creates!

-- Kerry, 6/20/2003