本文整理匯總了Java中android.media.AudioTrack.PLAYSTATE_STOPPED屬性的典型用法代碼示例。如果您正苦於以下問題:Java AudioTrack.PLAYSTATE_STOPPED屬性的具體用法?Java AudioTrack.PLAYSTATE_STOPPED怎麽用?Java AudioTrack.PLAYSTATE_STOPPED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.media.AudioTrack
的用法示例。
在下文中一共展示了AudioTrack.PLAYSTATE_STOPPED屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stopListening
/**
* 打斷(停止)喚醒,調用該方法後馬上停止錄音,但不保證完全打斷喚醒,完全打斷可能會有延遲
*/
public void stopListening(){
Log.i(TAG, "stopListening");
if(isListening())
try{
stopRecord();
if(at.getPlayState()!= AudioTrack.PLAYSTATE_STOPPED){
stopInterrupt.set(true);
}
}catch(Exception e){
e.printStackTrace();
}
}
示例2: 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();
}
示例3: 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;
}
示例4: startAudioTrack
private void startAudioTrack() {
if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>();
mAudioManager.listAudioPatches(patches);
mAudioTrack.play();
}
}