android.media.AudioTrack#PLAYSTATE_PAUSED源码实例Demo

下面列出了android.media.AudioTrack#PLAYSTATE_PAUSED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Saiy-PS   文件: SaiyTextToSpeech.java
@Override
public boolean isSpeaking() {

    if (audioTrack != null && audioTrack.getState() == AudioTrack.STATE_INITIALIZED) {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "isSpeaking: audioTrack STATE_INITIALIZED");
        }

        if (audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING
                || audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PAUSED) {
            if (DEBUG) {
                MyLog.i(CLS_NAME, "isSpeaking: audioTrack PLAYSTATE_PLAYING/PLAYSTATE_PAUSED");
            }
            return true;
        } else {
            if (DEBUG) {
                MyLog.i(CLS_NAME, "isSpeaking: audioTrack not playing");
            }
        }
    }

    final boolean speakingSuper = super.isSpeaking();

    if (DEBUG) {
        MyLog.i(CLS_NAME, "isSpeaking: speakingSuper " + speakingSuper);
    }

    return speakingSuper;
}
 
源代码2 项目: Saiy-PS   文件: SaiyTextToSpeech.java
@Override
public void shutdown() {

    if (audioTrack != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        switch (audioTrack.getPlayState()) {
            case AudioTrack.PLAYSTATE_PLAYING:
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "stop: PLAYSTATE_PLAYING");
                }
                audioTrack.stop(true);
                audioTrack.flush();
                audioTrack.release();
            case AudioTrack.PLAYSTATE_PAUSED:
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "stop: PLAYSTATE_PAUSED");
                }
                audioTrack.stop(true);
                audioTrack.flush();
                audioTrack.release();
            case AudioTrack.PLAYSTATE_STOPPED:
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "stop: PLAYSTATE_STOPPED");
                }
                audioTrack.flush();
                audioTrack.release();
                break;
        }
    }

    super.shutdown();
}
 
源代码3 项目: Saiy-PS   文件: SaiyTextToSpeech.java
@Override
public int stop() {

    if (audioTrack != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        switch (audioTrack.getPlayState()) {
            case AudioTrack.PLAYSTATE_PLAYING:
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "stop: PLAYSTATE_PLAYING");
                }
                audioTrack.stop(true);
                return SUCCESS;
            case AudioTrack.PLAYSTATE_PAUSED:
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "stop: PLAYSTATE_PAUSED");
                }
                audioTrack.stop(true);
                return SUCCESS;
            case AudioTrack.PLAYSTATE_STOPPED:
                if (DEBUG) {
                    MyLog.i(CLS_NAME, "stop: PLAYSTATE_STOPPED");
                }
                break;
        }
    }

    try {
        return super.stop();
    } catch (final NullPointerException e) {
        if (DEBUG) {
            MyLog.w(CLS_NAME, "stop: NullPointerException");
            e.printStackTrace();
        }
    }

    return ERROR;
}
 
源代码4 项目: MediaSDK   文件: AudioTrackPositionTracker.java
/**
 * 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;
}
 
源代码5 项目: YTPlayer   文件: SamplePlayer.java
public boolean isPaused() {
    return mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PAUSED;
}
 
/**
 * 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;
}
 
/**
 * 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;
}
 
源代码8 项目: Telegram-FOSS   文件: AudioTrackPositionTracker.java
/**
 * 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;
}
 
源代码9 项目: Telegram   文件: AudioTrackPositionTracker.java
/**
 * 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;
}