If recorded media is supported, PCM wav 8 bit, 8 KHZ format must be supported. Additional formats may be supported
MIDI may be supported
Like network operations, media operations must also be executed on separate threads, because resource loading and infrastructure access may consume time. A resource execution (start method) is not blocking ONLY when all resources are already loaded.
Classes at javax.microedition.media package.
API is based on three main classes: Manager, Player and Control.
playTone(note,duration,volume): Convenience method to play a tone. Plays a tone (integer from 0 to 127), during the specified time (milliseconds) using the specified volume ( 0 – 100). This method is non-blocking.
getSupportedContentTypes(protocol): Gets all supported content types for a specific protocol. If protocol is null, all supported content types are returned. Content types examples:
Players are created using Manager’s factory methods, and the media executions begins calling start() method. If all data is already loaded, this call is not blocking. If not interrupted, the execution proceeds until the end of the media.
start(): Starts the media execution. If the player is not at PREFETCHED state, it will be prefetched before the execution starts. If it’s already executing, the call is ignored. If it’s called on a interrupted player (interrupted by stop or media end) the execution continues from the point where it stopped. It’s not blocking if the player is PREFETCHED.
stop(): Stops the execution at the current point.
deallocate(): Deallocate all player’s resources and it returns it to REALIZED state. Useful for devices that do not support mixing and the buffers must be freed if another resource is to be executed.
close(): Finishes a player and deallocates all the resources it consumes.
setMediaTime(now): Sets the execution on a specific time. If it’s a negative value, the media returns at the beginning. If it’s bigger than the resource duration, it goes to the end. Some resources may not support this operation (e.g. live transmissions).
setLoopCount(count): Repeats the media execution. By default it’s 1. Setting 0 is not valid and setting -1 repeats indefinitely. It cannot be called by a STARTED player.
addPlayerListener(playerlistener), removePlayerListener(playerListener): Adds/Removes an event listener, which is notified everytime a player changes its state. Event ordering is kept.
Controllable: Object that “has controls”. Player implements Controllable.
getControls(): All controls supported by the object
getControl(controlType): Gets a control from its class name. If this control is not supported, null is returned. If the package name is omitted, it’s assumed that it belongs to javax.microedition.media package.