本文整理匯總了Java中android.media.AudioTrack.PLAYSTATE_PLAYING屬性的典型用法代碼示例。如果您正苦於以下問題:Java AudioTrack.PLAYSTATE_PLAYING屬性的具體用法?Java AudioTrack.PLAYSTATE_PLAYING怎麽用?Java AudioTrack.PLAYSTATE_PLAYING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.media.AudioTrack
的用法示例。
在下文中一共展示了AudioTrack.PLAYSTATE_PLAYING屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isSpeaking
/**
* 判斷當前合成引擎是否處於朗讀狀態
*
* @return true=是
*/
public boolean isSpeaking() {
boolean result = false;
try {
result = synthesizer.isSpeaking() || pcmPlayer.getPlayState() == AudioTrack.PLAYSTATE_PLAYING;
} catch (Exception e) {
e.printStackTrace();
}
Log.i(TAG, "isSpeaking>>" + Boolean.toString(result));
return result;
}
示例2: audioTrackWrite
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;
}
}
}
示例3: stopPlayer
public void stopPlayer() {
if (!mIsPlayStarted) {
return;
}
if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) {
mAudioTrack.stop();
}
mAudioTrack.release();
mIsPlayStarted = false;
Log.d(TAG, "Stop audio player success !");
}
示例4: isSpeaking
@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;
}
示例5: shutdown
@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();
}
示例6: stop
@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;
}
示例7: startAudioProcessing
public void startAudioProcessing(){
queueThread.start();
//while ( queueThread.isAlive() && ! m_line.isActive() ){
while ( queueThread.isAlive() && audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING){
Thread.yield();
}
/* Initialize the seconds time offset now that the line is running. */
secondsTimeOffset = 2208988800.0 + System.currentTimeMillis() * 1e-3;
}
示例8: audioTrackWrite
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;
}
}
}
示例9: interrupt
/**
* Interrupt the audioStream.
*/
public void interrupt() {
if (audioTrack != null) {
if (audioTrack.getState() == AudioTrack.STATE_INITIALIZED || audioTrack.getState() == AudioTrack.PLAYSTATE_PLAYING) {
audioTrack.pause();
}
audioTrack.flush();
audioTrack.release();
}
}
示例10: isRunning
@Override
public boolean isRunning() {
return (this.audioTrack != null && this.audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING);
}
示例11: isActive
@Override
public boolean isActive() {
return (this.audioTrack != null && this.audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING);
}
示例12: audioTrackStart
private void audioTrackStart() {
if (mAudioTrack != null && mAudioTrack.getState() == AudioTrack.STATE_INITIALIZED && mAudioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING)
mAudioTrack.play();
}
示例13: isPlaying
public boolean isPlaying() {
return mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING;
}
示例14: isPlaying
public boolean isPlaying() {
return mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING;
}
示例15: isPlaying
@Override
public boolean isPlaying() {
return audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING;
}