Example usage for android.media AudioTrack PLAYSTATE_STOPPED

List of usage examples for android.media AudioTrack PLAYSTATE_STOPPED

Introduction

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

Prototype

int PLAYSTATE_STOPPED

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

Click Source Link

Document

indicates AudioTrack state is stopped

Usage

From source file:com.tt.engtrain.showcontent.ContentListItemActivity.java

private void playSelfRecorde(final String path) {// pcm

    new Thread(new Runnable() {

        @Override//ww w .j a  v  a  2 s. c  o  m
        public void run() {
            // TODO Auto-generated method stub
            if (!(audioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED)) {
                audioTrack.stop();
                return;
            }
            audioTrack.play();

            byte[] data = getBytes(path);
            audioTrack.write(data, 0, data.length);
            audioTrack.stop();
        }
    }).start();

}