當前位置: 首頁>>代碼示例>>Java>>正文


Java AudioTrack.PLAYSTATE_STOPPED屬性代碼示例

本文整理匯總了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();
	}
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:15,代碼來源:WakeupEngineBase.java

示例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();
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:31,代碼來源:SaiyTextToSpeech.java

示例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;
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:36,代碼來源:SaiyTextToSpeech.java

示例4: startAudioTrack

private void startAudioTrack() {
    if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED) {
        ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>();
        mAudioManager.listAudioPatches(patches);
        mAudioTrack.play();
    }
}
 
開發者ID:KobeMing,項目名稱:FMRadio,代碼行數:7,代碼來源:FmService.java


注:本文中的android.media.AudioTrack.PLAYSTATE_STOPPED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。