public
class
JetPlayer
extends Object
java.lang.Object | |
↳ | android.media.JetPlayer |
JetPlayer provides access to JET content playback and control.
Please refer to the JET Creator User Manual for a presentation of the JET interactive music concept and how to use the JetCreator tool to create content to be player by JetPlayer.
Use of the JetPlayer class is based around the playback of a number of JET segments sequentially added to a playback FIFO queue. The rendering of the MIDI content stored in each segment can be dynamically affected by two mechanisms:
getJetPlayer()
to construct a JetPlayer instance. JetPlayer is a singleton class.
For more information about how to use JetPlayer, read the JetPlayer developer guide.
Nested classes | |
---|---|
interface |
JetPlayer.OnJetEventListener
Handles the notification when the JET engine generates an event. |
Public methods | |
---|---|
boolean
|
clearQueue()
Empties the segment queue, and clears all clips that are scheduled for playback. |
Object
|
clone()
Cloning a JetPlayer instance is not supported. |
boolean
|
closeJetFile()
Closes the resource containing the JET content. |
static
JetPlayer
|
getJetPlayer()
Factory method for the JetPlayer class. |
static
int
|
getMaxTracks()
Returns the maximum number of simultaneous MIDI tracks supported by JetPlayer |
boolean
|
loadJetFile(String path)
Loads a .jet file from a given path. |
boolean
|
loadJetFile(AssetFileDescriptor afd)
Loads a .jet file from an asset file descriptor. |
boolean
|
pause()
Pauses the playback of the JET segment queue. |
boolean
|
play()
Starts playing the JET segment queue. |
boolean
|
queueJetSegment(int segmentNum, int libNum, int repeatCount, int transpose, int muteFlags, byte userID)
Queues the specified segment in the JET queue. |
boolean
|
queueJetSegmentMuteArray(int segmentNum, int libNum, int repeatCount, int transpose, boolean[] muteArray, byte userID)
Queues the specified segment in the JET queue. |
void
|
release()
Stops the current JET playback, and releases all associated native resources. |
void
|
setEventListener(JetPlayer.OnJetEventListener listener)
Sets the listener JetPlayer notifies when a JET event is generated by the rendering and playback engine. |
void
|
setEventListener(JetPlayer.OnJetEventListener listener, Handler handler)
Sets the listener JetPlayer notifies when a JET event is generated by the rendering and playback engine. |
boolean
|
setMuteArray(boolean[] muteArray, boolean sync)
Modifies the mute flags for the current active segment. |
boolean
|
setMuteFlag(int trackId, boolean muteFlag, boolean sync)
Mutes or unmutes a single track. |
boolean
|
setMuteFlags(int muteFlags, boolean sync)
Modifies the mute flags. |
boolean
|
triggerClip(int clipId)
Schedules the playback of a clip. |
Protected methods | |
---|---|
void
|
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
boolean clearQueue ()
Empties the segment queue, and clears all clips that are scheduled for playback.
Returns | |
---|---|
boolean |
true if the queue was successfully cleared, false otherwise. |
Object clone ()
Cloning a JetPlayer instance is not supported. Calling clone() will generate an exception.
Returns | |
---|---|
Object |
a clone of this instance. |
Throws | |
---|---|
CloneNotSupportedException |
boolean closeJetFile ()
Closes the resource containing the JET content.
Returns | |
---|---|
boolean |
true if successfully closed, false otherwise. |
JetPlayer getJetPlayer ()
Factory method for the JetPlayer class.
Returns | |
---|---|
JetPlayer |
the singleton JetPlayer instance |
int getMaxTracks ()
Returns the maximum number of simultaneous MIDI tracks supported by JetPlayer
Returns | |
---|---|
int |
boolean loadJetFile (String path)
Loads a .jet file from a given path.
Parameters | |
---|---|
path |
String :
the path to the .jet file, for instance "/sdcard/mygame/music.jet". |
Returns | |
---|---|
boolean |
true if loading the .jet file was successful, false if loading failed. |
boolean loadJetFile (AssetFileDescriptor afd)
Loads a .jet file from an asset file descriptor.
Parameters | |
---|---|
afd |
AssetFileDescriptor :
the asset file descriptor. |
Returns | |
---|---|
boolean |
true if loading the .jet file was successful, false if loading failed. |
boolean pause ()
Pauses the playback of the JET segment queue.
Returns | |
---|---|
boolean |
true if rendering and playback is successfully paused, false otherwise. |
boolean play ()
Starts playing the JET segment queue.
Returns | |
---|---|
boolean |
true if rendering and playback is successfully started, false otherwise. |
boolean queueJetSegment (int segmentNum, int libNum, int repeatCount, int transpose, int muteFlags, byte userID)
Queues the specified segment in the JET queue.
Parameters | |
---|---|
segmentNum |
int :
the identifier of the segment. |
libNum |
int :
the index of the sound bank associated with the segment. Use -1 to indicate
that no sound bank (DLS file) is associated with this segment, in which case JET will use
the General MIDI library. |
repeatCount |
int :
the number of times the segment will be repeated. 0 means the segment will
only play once. -1 means the segment will repeat indefinitely. |
transpose |
int :
the amount of pitch transposition. Set to 0 for normal playback.
Range is -12 to +12. |
muteFlags |
int :
a bitmask to specify which MIDI tracks will be muted during playback. Bit 0
affects track 0, bit 1 affects track 1 etc. |
userID |
byte :
a value specified by the application that uniquely identifies the segment.
this value is received in the
onJetUserIdUpdate(JetPlayer, int, int) event listener method.
Normally, the application will keep a byte value that is incremented each time a new
segment is queued up. This can be used to look up any special characteristics of that
track including trigger clips and mute flags. |
Returns | |
---|---|
boolean |
true if the segment was successfully queued, false if the queue is full or if the parameters are invalid. |
boolean queueJetSegmentMuteArray (int segmentNum, int libNum, int repeatCount, int transpose, boolean[] muteArray, byte userID)
Queues the specified segment in the JET queue.
Parameters | |
---|---|
segmentNum |
int :
the identifier of the segment. |
libNum |
int :
the index of the soundbank associated with the segment. Use -1 to indicate that
no sound bank (DLS file) is associated with this segment, in which case JET will use
the General MIDI library. |
repeatCount |
int :
the number of times the segment will be repeated. 0 means the segment will
only play once. -1 means the segment will repeat indefinitely. |
transpose |
int :
the amount of pitch transposition. Set to 0 for normal playback.
Range is -12 to +12. |
muteArray |
boolean :
an array of booleans to specify which MIDI tracks will be muted during
playback. The value at index 0 affects track 0, value at index 1 affects track 1 etc.
The length of the array must be getMaxTracks() for the call to succeed. |
userID |
byte :
a value specified by the application that uniquely identifies the segment.
this value is received in the
onJetUserIdUpdate(JetPlayer, int, int) event listener method.
Normally, the application will keep a byte value that is incremented each time a new
segment is queued up. This can be used to look up any special characteristics of that
track including trigger clips and mute flags. |
Returns | |
---|---|
boolean |
true if the segment was successfully queued, false if the queue is full or if the parameters are invalid. |
void release ()
Stops the current JET playback, and releases all associated native resources. The object can no longer be used and the reference should be set to null after a call to release().
void setEventListener (JetPlayer.OnJetEventListener listener)
Sets the listener JetPlayer notifies when a JET event is generated by the rendering and playback engine. Notifications will be received in the same thread as the one in which the JetPlayer instance was created.
void setEventListener (JetPlayer.OnJetEventListener listener, Handler handler)
Sets the listener JetPlayer notifies when a JET event is generated by the rendering and playback engine. Use this method to receive JET events in the Handler associated with another thread than the one in which you created the JetPlayer instance.
Parameters | |
---|---|
handler |
Handler :
the Handler that will receive the event notification messages.
|
boolean setMuteArray (boolean[] muteArray, boolean sync)
Modifies the mute flags for the current active segment.
Parameters | |
---|---|
muteArray |
boolean :
an array of booleans to specify which MIDI tracks are muted. The value at
index 0 affects track 0, value at index 1 affects track 1 etc.
The length of the array must be getMaxTracks() for the call to succeed. |
sync |
boolean :
if false, the new mute flags will be applied as soon as possible by the JET
render and playback engine. If true, the mute flags will be updated at the start of the
next segment. If the segment is repeated, the flags will take effect the next time
segment is repeated. |
Returns | |
---|---|
boolean |
true if the mute flags were successfully updated, false otherwise. |
boolean setMuteFlag (int trackId, boolean muteFlag, boolean sync)
Mutes or unmutes a single track.
Parameters | |
---|---|
trackId |
int :
the index of the track to mute. |
muteFlag |
boolean :
set to true to mute, false to unmute. |
sync |
boolean :
if false, the new mute flags will be applied as soon as possible by the JET
render and playback engine. If true, the mute flag will be updated at the start of the
next segment. If the segment is repeated, the flag will take effect the next time
segment is repeated. |
Returns | |
---|---|
boolean |
true if the mute flag was successfully updated, false otherwise. |
boolean setMuteFlags (int muteFlags, boolean sync)
Modifies the mute flags.
Parameters | |
---|---|
muteFlags |
int :
a bitmask to specify which MIDI tracks are muted. Bit 0 affects track 0,
bit 1 affects track 1 etc. |
sync |
boolean :
if false, the new mute flags will be applied as soon as possible by the JET
render and playback engine. If true, the mute flags will be updated at the start of the
next segment. If the segment is repeated, the flags will take effect the next time
segment is repeated. |
Returns | |
---|---|
boolean |
true if the mute flags were successfully updated, false otherwise. |
boolean triggerClip (int clipId)
Schedules the playback of a clip. This will automatically update the mute flags in sync with the JET Clip Marker (controller 103). The parameter clipID must be in the range of 0-63. After the call to triggerClip, when JET next encounters a controller event 103 with bits 0-5 of the value equal to clipID and bit 6 set to 1, it will automatically unmute the track containing the controller event. When JET encounters the complementary controller event 103 with bits 0-5 of the value equal to clipID and bit 6 set to 0, it will mute the track again.
Parameters | |
---|---|
clipId |
int :
the identifier of the clip to trigger. |
Returns | |
---|---|
boolean |
true if the clip was successfully triggered, false otherwise. |
void finalize ()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
A subclass overrides the finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.