Most visited

Recently visited

Added in API level 3

JetPlayer

public class JetPlayer
extends Object

java.lang.Object
   ↳ android.media.JetPlayer


JetPlayer提供对JET内容回放和控制的访问。

请参阅JET Creator用户手册,了解JET交互式音乐概念以及如何使用JetCreator工具创建内容以便由JetPlayer播放。

JetPlayer类的使用基于顺序添加到回放FIFO队列的多个JET段的回放。 存储在每个段中的MIDI内容的渲染可以通过两种机制动态地影响:

As a result of the rendering and playback of the JET segments, the user of the JetPlayer instance can receive notifications from the JET engine relative to: Use getJetPlayer() to construct a JetPlayer instance. JetPlayer is a singleton class.

Developer Guides

有关如何使用JetPlayer的更多信息,请阅读 JetPlayer开发人员指南。

Summary

Nested classes

interface JetPlayer.OnJetEventListener

JET引擎生成事件时处理通知。

Public methods

boolean clearQueue()

清空细分队列,并清除预定要播放的所有剪辑。

Object clone()

不支持克隆JetPlayer实例。

boolean closeJetFile()

关闭包含JET内容的资源。

static JetPlayer getJetPlayer()

JetPlayer类的工厂方法。

static int getMaxTracks()

返回JetPlayer支持的同时MIDI轨道的最大数量

boolean loadJetFile(String path)

从给定路径加载.jet文件。

boolean loadJetFile(AssetFileDescriptor afd)

从资产文件描述符加载.jet文件。

boolean pause()

暂停播放JET段队列。

boolean play()

开始播放JET段队列。

boolean queueJetSegment(int segmentNum, int libNum, int repeatCount, int transpose, int muteFlags, byte userID)

在JET队列中排队指定的段。

boolean queueJetSegmentMuteArray(int segmentNum, int libNum, int repeatCount, int transpose, boolean[] muteArray, byte userID)

在JET队列中排队指定的段。

void release()

停止当前的JET回放,并释放所有关联的本机资源。

void setEventListener(JetPlayer.OnJetEventListener listener)

设置侦听器JetPlayer在渲染和回放引擎生成JET事件时通知。

void setEventListener(JetPlayer.OnJetEventListener listener, Handler handler)

设置侦听器JetPlayer在渲染和回放引擎生成JET事件时通知。

boolean setMuteArray(boolean[] muteArray, boolean sync)

修改当前活动段的静音标志。

boolean setMuteFlag(int trackId, boolean muteFlag, boolean sync)

静音或取消静音单曲。

boolean setMuteFlags(int muteFlags, boolean sync)

修改静音标志。

boolean triggerClip(int clipId)

计划剪辑的播放。

Protected methods

void finalize()

当垃圾收集确定没有更多对该对象的引用时,由对象上的垃圾回收器调用。

Inherited methods

From class java.lang.Object

Public methods

clearQueue

Added in API level 3
boolean clearQueue ()

清空细分队列,并清除预定要播放的所有剪辑。

Returns
boolean true if the queue was successfully cleared, false otherwise.

clone

Added in API level 3
Object clone ()

不支持克隆JetPlayer实例。 调用clone()会产生一个异常。

Returns
Object a clone of this instance.
Throws
CloneNotSupportedException

closeJetFile

Added in API level 3
boolean closeJetFile ()

关闭包含JET内容的资源。

Returns
boolean true if successfully closed, false otherwise.

getJetPlayer

Added in API level 3
JetPlayer getJetPlayer ()

JetPlayer类的工厂方法。

Returns
JetPlayer the singleton JetPlayer instance

getMaxTracks

Added in API level 3
int getMaxTracks ()

返回JetPlayer支持的同时MIDI轨道的最大数量

Returns
int

loadJetFile

Added in API level 3
boolean loadJetFile (String path)

从给定路径加载.jet文件。

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.

loadJetFile

Added in API level 3
boolean loadJetFile (AssetFileDescriptor afd)

从资产文件描述符加载.jet文件。

Parameters
afd AssetFileDescriptor: the asset file descriptor.
Returns
boolean true if loading the .jet file was successful, false if loading failed.

pause

Added in API level 3
boolean pause ()

暂停播放JET段队列。

Returns
boolean true if rendering and playback is successfully paused, false otherwise.

play

Added in API level 3
boolean play ()

开始播放JET段队列。

Returns
boolean true if rendering and playback is successfully started, false otherwise.

queueJetSegment

Added in API level 3
boolean queueJetSegment (int segmentNum, 
                int libNum, 
                int repeatCount, 
                int transpose, 
                int muteFlags, 
                byte userID)

在JET队列中排队指定的段。

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.

queueJetSegmentMuteArray

Added in API level 3
boolean queueJetSegmentMuteArray (int segmentNum, 
                int libNum, 
                int repeatCount, 
                int transpose, 
                boolean[] muteArray, 
                byte userID)

在JET队列中排队指定的段。

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.

release

Added in API level 3
void release ()

停止当前的JET回放,并释放所有关联的本机资源。 该对象不能再使用,并且在调用release()之后应将该引用设置为null。

setEventListener

Added in API level 3
void setEventListener (JetPlayer.OnJetEventListener listener)

设置侦听器JetPlayer在渲染和回放引擎生成JET事件时通知。 通知将在与创建JetPlayer实例的线程相同的线程中接收。

setEventListener

Added in API level 3
void setEventListener (JetPlayer.OnJetEventListener listener, 
                Handler handler)

设置侦听器JetPlayer在渲染和回放引擎生成JET事件时通知。 使用此方法在Handler中接收与创建JetPlayer实例的线程相关的JET事件。

Parameters
handler Handler: the Handler that will receive the event notification messages.

setMuteArray

Added in API level 3
boolean setMuteArray (boolean[] muteArray, 
                boolean sync)

修改当前活动段的静音标志。

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.

setMuteFlag

Added in API level 3
boolean setMuteFlag (int trackId, 
                boolean muteFlag, 
                boolean sync)

静音或取消静音单曲。

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.

setMuteFlags

Added in API level 3
boolean setMuteFlags (int muteFlags, 
                boolean sync)

修改静音标志。

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.

triggerClip

Added in API level 3
boolean triggerClip (int clipId)

计划剪辑的播放。 这将自动更新与JET剪辑标记(控制器103)同步的静音标记。 参数clipID必须在0-63的范围内。 在调用triggerClip之后,当JET下一个遇到控制器事件103,其位0-5的值等于clipID且位6设置为1时,它将自动取消静音含有控制器事件的轨道。 当JET遇到互补控制器事件103,其中位0-5的值等于clipID且位6设置为0时,它将再次静音轨道。

Parameters
clipId int: the identifier of the clip to trigger.
Returns
boolean true if the clip was successfully triggered, false otherwise.

Protected methods

finalize

Added in API level 3
void finalize ()

当垃圾收集确定没有更多对该对象的引用时,由对象上的垃圾回收器调用。 子类重写finalize方法来处置系统资源或执行其他清理。

的常规协定finalize是,它被调用,如果当在Java TM虚拟机已确定不再有由该目的可以通过还没有死亡,除了作为一个动作的结果的任何线程访问的任何手段取决于某些其他可以完成的对象或类别的最终定稿。 finalize方法可以采取任何行动,包括再制作该对象提供给其他线程; 然而, finalize的通常目的是在对象被不可撤销地丢弃之前执行清理操作。 例如,表示输入/输出连接的对象的finalize方法可能会执行显式I / O事务,以在永久丢弃该对象之前中断连接。

Objectfinalize方法Object执行特殊操作; 它只是正常返回。 Object子类可能会覆盖此定义。

Java编程语言不保证哪个线程将为任何给定的对象调用finalize方法。 但是,保证调用finalize的线程在调用finalize时不会保留任何用户可见的同步锁。 如果finalize方法引发未捕获的异常,则忽略该异常,并终止该对象的终止。

在针对对象调用 finalize方法之后,在Java虚拟机再次确定不再有任何方法可以通过尚未死亡的任何线程访问此对象,包括可能的操作通过准备完成的其他对象或类别,此时该对象可能被丢弃。

对于任何给定的对象,Java虚拟机从不会多次调用 finalize方法。

finalize方法抛出的任何异常 finalize导致此对象的终止被暂停,但会被忽略。

Hooray!