Example usage for android.media AudioTrack STATE_UNINITIALIZED

List of usage examples for android.media AudioTrack STATE_UNINITIALIZED

Introduction

In this page you can find the example usage for android.media AudioTrack STATE_UNINITIALIZED.

Prototype

int STATE_UNINITIALIZED

To view the source code for android.media AudioTrack STATE_UNINITIALIZED.

Click Source Link

Document

State of an AudioTrack that was not successfully initialized upon creation.

Usage

From source file:com.ibm.watson.developer_cloud.android.text_to_speech.v1.TTSUtility.java

/**
 * Stop player//from  w  w w.  j  a v  a  2s.  c o m
 */
private void stopTtsPlayer() {
    if (audioTrack != null && audioTrack.getState() != AudioTrack.STATE_UNINITIALIZED) {
        // IMPORTANT: NOT use stop()
        // For an immediate stop, use pause(), followed by flush() to discard audio data that hasn't been played back yet.
        audioTrack.pause();
        audioTrack.flush();
    }
}