本文整理汇总了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();
}
}