IT. Expert System.

Android Reference

JetPlayer


android.media

Class JetPlayer



  • public class JetPlayer
    extends Object
    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:

    • tracks in a segment can be muted or unmuted at any moment, individually or through a mask (to change the mute state of multiple tracks at once)
    • parts of tracks in a segment can be played at predefined points in the segment, in order to maintain synchronization with the other tracks in the segment. This is achieved through the notion of "clips", which can be triggered at any time, but that will play only at the right time, as authored in the corresponding JET file.
    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:
    • the playback state,
    • the number of segments left to play in the queue,
    • application controller events (CC80-83) to mark points in the MIDI segments.
    Use getJetPlayer() to construct a JetPlayer instance. JetPlayer is a singleton class.

    Developer Guides

    For more information about how to use JetPlayer, read the JetPlayer developer guide.

    • Nested Class Summary

      Nested Classes
      Modifier and Type Class and Description
      static interface JetPlayer.OnJetEventListener
      Handles the notification when the JET engine generates an event.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      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.
      protected void finalize()
      Invoked when the garbage collector has detected that this instance is no longer reachable.
      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(AssetFileDescriptor afd)
      Loads a .jet file from an asset file descriptor.
      boolean loadJetFile(String path)
      Loads a .jet file from a given path.
      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.
    • Method Detail

      • getJetPlayer

        public static JetPlayer getJetPlayer()
        Factory method for the JetPlayer class.
        Returns:
        the singleton JetPlayer instance
      • finalize

        protected void finalize()
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        Overrides:
        finalize in class Object
      • release

        public 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().
      • getMaxTracks

        public static int getMaxTracks()
        Returns the maximum number of simultaneous MIDI tracks supported by JetPlayer
      • loadJetFile

        public boolean loadJetFile(String path)
        Loads a .jet file from a given path.
        Parameters:
        path - the path to the .jet file, for instance "/sdcard/mygame/music.jet".
        Returns:
        true if loading the .jet file was successful, false if loading failed.
      • loadJetFile

        public boolean loadJetFile(AssetFileDescriptor afd)
        Loads a .jet file from an asset file descriptor.
        Parameters:
        afd - the asset file descriptor.
        Returns:
        true if loading the .jet file was successful, false if loading failed.
      • closeJetFile

        public boolean closeJetFile()
        Closes the resource containing the JET content.
        Returns:
        true if successfully closed, false otherwise.
      • play

        public boolean play()
        Starts playing the JET segment queue.
        Returns:
        true if rendering and playback is successfully started, false otherwise.
      • pause

        public boolean pause()
        Pauses the playback of the JET segment queue.
        Returns:
        true if rendering and playback is successfully paused, false otherwise.
      • queueJetSegment

        public boolean queueJetSegment(int segmentNum,
                              int libNum,
                              int repeatCount,
                              int transpose,
                              int muteFlags,
                              byte userID)
        Queues the specified segment in the JET queue.
        Parameters:
        segmentNum - the identifier of the segment.
        libNum - 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 - 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 - the amount of pitch transposition. Set to 0 for normal playback. Range is -12 to +12.
        muteFlags - a bitmask to specify which MIDI tracks will be muted during playback. Bit 0 affects track 0, bit 1 affects track 1 etc.
        userID - a value specified by the application that uniquely identifies the segment. this value is received in the JetPlayer.OnJetEventListener.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:
        true if the segment was successfully queued, false if the queue is full or if the parameters are invalid.
      • queueJetSegmentMuteArray

        public boolean queueJetSegmentMuteArray(int segmentNum,
                                       int libNum,
                                       int repeatCount,
                                       int transpose,
                                       boolean[] muteArray,
                                       byte userID)
        Queues the specified segment in the JET queue.
        Parameters:
        segmentNum - the identifier of the segment.
        libNum - 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 - 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 - the amount of pitch transposition. Set to 0 for normal playback. Range is -12 to +12.
        muteArray - 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 - a value specified by the application that uniquely identifies the segment. this value is received in the JetPlayer.OnJetEventListener.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:
        true if the segment was successfully queued, false if the queue is full or if the parameters are invalid.
      • setMuteFlags

        public boolean setMuteFlags(int muteFlags,
                           boolean sync)
        Modifies the mute flags.
        Parameters:
        muteFlags - a bitmask to specify which MIDI tracks are muted. Bit 0 affects track 0, bit 1 affects track 1 etc.
        sync - 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:
        true if the mute flags were successfully updated, false otherwise.
      • setMuteArray

        public boolean setMuteArray(boolean[] muteArray,
                           boolean sync)
        Modifies the mute flags for the current active segment.
        Parameters:
        muteArray - 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 - 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:
        true if the mute flags were successfully updated, false otherwise.
      • setMuteFlag

        public boolean setMuteFlag(int trackId,
                          boolean muteFlag,
                          boolean sync)
        Mutes or unmutes a single track.
        Parameters:
        trackId - the index of the track to mute.
        muteFlag - set to true to mute, false to unmute.
        sync - 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:
        true if the mute flag was successfully updated, false otherwise.
      • triggerClip

        public 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 - the identifier of the clip to trigger.
        Returns:
        true if the clip was successfully triggered, false otherwise.
      • clearQueue

        public boolean clearQueue()
        Empties the segment queue, and clears all clips that are scheduled for playback.
        Returns:
        true if the queue was successfully cleared, false otherwise.
      • setEventListener

        public 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.
        Parameters:
        listener -
      • setEventListener

        public 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:
        listener -
        handler - the Handler that will receive the event notification messages.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 672 / . Delta: 0.05656 с