Using Sprint MIDP 1.0 Extensions
Vendor-specific APIs are useful when you need to take advantage of functionality not available in the core MIDP APIs, and you don’t mind locking your application into a single platform. I happen to have a Sprint cell phone, so we will use this as our vendor-specific example in this tutorial. First, we will learn how to use the Sprint Wireless Toolkit 3.0 platform and emulators in NetBeans IDE. Then, we will then use the Sprint MIDP 1.0 Extensions to create a MIDlet that plays sound on a Sprint PCS cell phone with only MIDP 1.0 support and no MMAPI support.
First, go to the Sprint PCS Application Developer website, download the Sprint Wireless Toolkit 3.0, and install it on your development PC. This toolkit will provide you with a new platform which you can use to develop and test applications using the Sprint MIDP Extensions. Note that you must be using JDK 5.0 in order to use Sprint Wireless Toolkit 3.0.
There is one additional step that must be taken in order to play QCELP sounds from the Sprint Wireless Toolkit 3.0 emulator. Download the PureVoice Player/Recorder. The ZIP file will contain a file named “qscl.dll”. This file needs to be copied into the “bin” directory of the Sprint Wireless Toolkit, e.g. “C:\SPRINT_WTK\bin”. I’m not sure why this wasn’t included with the toolkit to begin with; in fact, I only found this information by reading through a post on the Sprint PCS Developer message boards.

Next, we will add the new platform to our NetBeans installation. Launch NetBeans, and from the menu bar, choose Tools > Platform Manager. On the “Java Platform Manager” dialog, click the “Add Platform” button.

Next, select “Java Micro Edition Platform Emulator,” and click “Next.”

On the next screen, you should see the folder where you just installed the Sprint Wireless Toolkit listed under folders. If you do not, use the “Find More Java ME Platform Folders” button to find the folder where you installed the Sprint Wireless Toolkit. Once it is in the list, make sure the Sprint Wireless Toolkit is selected and click “Next.”

On the final screen, you should see a confirmation for the platform you selected. Click “Finish.”

Now, the Sprint Wireless Toolkit can be used as a platform for you Java ME projects. Let’s add some sound using the Sprint MIDP 1.0 Extensions. Going back to our demo project from the last tutorial, let’s change the platform for our project to use the Sprint Wireless Toolkit we just installed. Right-click on the project, and select “Properties” from the context menu. Under the “Category” tree, select “Platform.” For “Emulator Platform,” select “Sprint Wireless Toolkit.” You may choose any device. For the sake of this tutorial, I am choosing “Nokia 6165.” For the configuration, choose CLDC 1.0, and for the profile, choose MIDP 1.0. Under “Optional Packages,” make sure that “Sprint Extensions APIs 1.0″ is selected; you may need to scroll down to find it.
As the documentation for the Sprint MIDP 1.0 Extensions describes, both MIDI data and sampled sounds are supported. Sampled sounds must be QCELP-encoded. Since generating such files is beyond the scope of this tutorial, I’m providing a sample you can use. Take the file sound.qcp and add it as a resource to your NetBeans project. The easiest way to do this is to put it somewhere under your “src” directory.
Next, open the source file for your canvas class. Add the line below to import the media APIs from the Sprint MIDP Extensions.
import com.sprintpcs.media.*;
Now, we will load the sound resource in the constructor. Add a data member for the Clip object, and add code to the constructor to load the clip. Be sure to use the “audio/vnd.qcelp” MIME type rather than “audio/qcelp”; in my testing, the later only works in the emulator, and not on the device.
public MyCanvas() {</p><p> try {</p><p> // Create a new clip object
clip = new Clip(
"resource:com/dbarnes/demomidlet/sound.qcp",
"audio/vnd.qcelp", // MIME type
1, // Priority
0 // Seconds of vibration
);</p><p> } catch(IOException e) {
System.err.println("Problem creating Clip");
}
}</p><p>private Clip clip;
Next, update the following code in the run() method to cause the sound to be played every time the red ball reaches the edge of the screen.
// Determine if circle has reached edge
if(x + CIRCLE_DIAMETER + xVel >= getWidth()
|| x + xVel < 0) {</p><p> // Reverse velocity
xVel = -xVel;</p><p> // Play sound
Player.playBackground(
clip, // Clip object
0 // Do not repeat
);</p><p>}
Now compile the project, and run the MIDlet in the Sprint Wireless Toolkit emulator. Assuming the volume on your PC is turned up, you should be able to hear a sound every time the ball collides with the edge of the screen.
If you have a Sprint PCS phone, you can download the completed MIDlet from the following URL using your wireless web browser:
http://www.dbarnes.com/wap
The complete source code for the project described in this tutorial can be downloaded here: Source Code
Bookmark this article: del.icio.us Digg Furl Reddit blogmarks Google Spurl StumbleUpon Technorati Yahoo!
November 21st, 2006 at 7:17 pm
I have an Audiovox CDM-8910 phone from Bell Mobility in Canada. I downloaded the MIDlet from my phone and sound works. It’s nice to finally see how I can have sound on my MIDP 1.0 phone. Thanks!
November 21st, 2006 at 11:04 pm
I first installed the “Sprint Wireless Toolkit 3.0″ to “c:\Program Files\Java\SPRINT_WTK”. The NetBeans 5.5 Java Platform Manager would find it but automatic detection would fail. I eventually found that automatic detection worked if I installed it to “c:\SPRINT_WTK”. I could then easily compile and run the code from this page. There is also the Sprint Mobility IDE which is currently based on NetBeans 5.0. It seems to have some Sprint-specific modules.
November 22nd, 2006 at 4:15 am
My Audiovox CDM-8910 from Bell Mobility supports MP3 ringers as long as the content type is audio/midi. I tried the same thing with a 48 kbit 22.05 kHz mono MP3 and this code and it worked. When I used the correct MIME type, audio/mpeg, no sound was produced.
January 24th, 2007 at 12:00 pm
I have a sprint v3m and have downloaded my own games to it. Some games I put on work fine, except that they have no sound. Any demo i download from sprint, the sound works on all of those. I need to know how to make the sound work on the games I download. Program I have to edit is bitpim.
Any help would be appriciated. thank you