/** Returns whether the audio track is in the playing state. */ public boolean isPlaying() { return Assertions.checkNotNull(audioTrack).getPlayState() == PLAYSTATE_PLAYING; }
/** * If passthrough workarounds are enabled, pausing is implemented by forcing the AudioTrack to * underrun. In this case, still behave as if we have pending data, otherwise writing won't * resume. */ private boolean forceHasPendingData() { return needsPassthroughWorkarounds && Assertions.checkNotNull(audioTrack).getPlayState() == AudioTrack.PLAYSTATE_PAUSED && getPlaybackHeadPosition() == 0; }
int state = audioTrack.getPlayState(); if (state == PLAYSTATE_STOPPED) {
@PlayState int playState = Assertions.checkNotNull(audioTrack).getPlayState(); if (needsPassthroughWorkarounds) {
public long getCurrentPositionUs(boolean sourceEnded) { if (Assertions.checkNotNull(this.audioTrack).getPlayState() == PLAYSTATE_PLAYING) { maybeSampleSyncParams();
private void audioTrackWrite(byte[] audioData, int offsetInBytes, int sizeInBytes) { if (mAudioTrack != null && mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) { int written; while (sizeInBytes > 0) { written = sizeInBytes > mAudioTrackBufferSize ? mAudioTrackBufferSize : sizeInBytes; mAudioTrack.write(audioData, offsetInBytes, written); sizeInBytes -= written; offsetInBytes += written; } } }
private void audioTrackStart() { if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) mAudioTrack.play(); }
public boolean isPaused() { return mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PAUSED; }
public boolean isPlaying() { return mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING; }
private void audioTrackWrite(byte[] audioData, int offsetInBytes, int sizeInBytes) { if (mAudioTrack != null && mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) { int written; while (sizeInBytes > 0) { written = sizeInBytes > mAudioTrackBufferSize ? mAudioTrackBufferSize : sizeInBytes; mAudioTrack.write(audioData, offsetInBytes, written); sizeInBytes -= written; offsetInBytes += written; } } }
private void audioTrackWrite(byte[] audioData, int offsetInBytes, int sizeInBytes) { if (mAudioTrack != null && mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) { int written; while (sizeInBytes > 0) { written = sizeInBytes > mAudioTrackBufferSize ? mAudioTrackBufferSize : sizeInBytes; mAudioTrack.write(audioData, offsetInBytes, written); sizeInBytes -= written; offsetInBytes += written; } } }
private void audioTrackWrite(byte[] audioData, int offsetInBytes, int sizeInBytes) { if (mAudioTrack != null && mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) { int written; while (sizeInBytes > 0) { written = sizeInBytes > mAudioTrackBufferSize ? mAudioTrackBufferSize : sizeInBytes; mAudioTrack.write(audioData, offsetInBytes, written); sizeInBytes -= written; offsetInBytes += written; } } }
private void audioTrackWrite(byte[] audioData, int offsetInBytes, int sizeInBytes) { if (mAudioTrack != null && mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) { int written; while (sizeInBytes > 0) { written = sizeInBytes > mAudioTrackBufferSize ? mAudioTrackBufferSize : sizeInBytes; mAudioTrack.write(audioData, offsetInBytes, written); sizeInBytes -= written; offsetInBytes += written; } } }
/** * Returns whether the audio track should behave as though it has pending data. This is to work * around an issue on platform API versions 21/22 where AC-3 audio tracks can't be paused, so we * empty their buffers when paused. In this case, they should still behave as if they have * pending data, otherwise writing will never resume. * * @see #handleBuffer */ public boolean overrideHasPendingData() { return Util.SDK_INT <= 22 && isPassthrough && audioTrack.getPlayState() == android.media.AudioTrack.PLAYSTATE_PAUSED && audioTrack.getPlaybackHeadPosition() == 0; }
public void stopPlayer() { if (!mIsPlayStarted) { return; } if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) { mAudioTrack.stop(); } mAudioTrack.release(); mIsPlayStarted = false; Log.i(TAG, "Stop audio player success !"); }
private void audioTrackStart() { if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) mAudioTrack.play(); }
private void audioTrackStart() { if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) mAudioTrack.play(); }
private void audioTrackStart() { if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) mAudioTrack.play(); }
private void audioTrackStart() { if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) mAudioTrack.play(); }
private void audioTrackStart() { if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) mAudioTrack.play(); }