Code example for AudioTrack

Methods: getPlayStateplaywrite

0
    } 
 
    void writeSamples(short[] samples, int size) {
        if (running) {
            if (audioTrack != null) {
                audioTrack.write(samples, 0, size);
                if (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING)
                    play(); 
            } 
        } 
    } 
 
    void play() { 
        if (null == audioTrack) return;
        audioTrack.play();
    } 
 
    void pause() { 
        if (null == audioTrack) return;
        audioTrack.pause();
    }