Java Reference
In-Depth Information
The note is passed as an integer value in the range 0-127; ToneCon-
trol.C4 = 60 represents middle C. Adding or subtracting 1 increases
or lowers the pitch by a semitone. The duration is specified in milliseconds
and the volume is an integer value on the scale 0-100.
To play a sequence of tones it is more appropriate to create a Player
and use it to obtain a ToneControl :
{
byte[] toneSequence =
ToneControl.C4, ToneControl.C4 + 2,
ToneControl.c4 + 4, ... } ;
try {
Player player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
player.realize();
ToneControl control = (ToneControl)player.getControl("ToneControl");
control.setSequence(toneSequence);
player.start();
} catch (IOException ioe) {}
catch (MediaException me)
{
}
// handle
A tone sequence is specified as a list of tone-duration pairs and
user-defined sequence blocks, using ABNF syntax (refer to the MMAPI
specification for more detail). The list is packaged as a byte array and
passedtothe ToneControl using the setSequence() method. To play
the sequence, we simply invoke the start() method of the Player .
A more sophisticated example can be found in the documentation of
ToneControl in the MMAPI specification.
2.9.8 MMAPI on Symbian OS Phones
If you know which of the Symbian OS platforms you are targeting with
a MIDlet, you can craft your code to conform to the cited capabilities.
However, in practice it is more likely that you will want to write portable
code which can run on several or all of the platforms, or indeed on
non-Symbian OS phones with MMAPI capability. In this case, your
applications need to be able to work out the supported capabilities
dynamically and make use of what is available, or fail gracefully (for
example, by removing certain options from menus), if the capability you
want is just not available.
2.9.9 MMAPI and the MIDP Security Model
For reasons of privacy, the following Mobile Media API calls are restricted
under the MIDP security model (see the MobileMediaAPISpecification
1.1MaintenanceReleaseat jcp.org ):
RecordControl.setRecordLocation(String locator)
 
Search WWH ::




Custom Search