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


Java AudioTrack.STATE_UNINITIALIZED屬性代碼示例

本文整理匯總了Java中android.media.AudioTrack.STATE_UNINITIALIZED屬性的典型用法代碼示例。如果您正苦於以下問題:Java AudioTrack.STATE_UNINITIALIZED屬性的具體用法?Java AudioTrack.STATE_UNINITIALIZED怎麽用?Java AudioTrack.STATE_UNINITIALIZED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.media.AudioTrack的用法示例。


在下文中一共展示了AudioTrack.STATE_UNINITIALIZED屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: stop

@Override
public void stop() {
    getAudioTrackCurrentPosition();
    mCurrentState = PlayState.STOPPED;
    if (writeWorkThread != null) {
        writeWorkThread.stopWrite();
    }
    try {
        Log.d(TAG, "stop-PlayState:" + mAudioTrack.getPlayState());
        if (mAudioTrack != null && mAudioTrack.getPlayState() != AudioTrack.STATE_UNINITIALIZED) {
            mAudioTrack.pause();
            mAudioTrack.flush();
            Log.d(TAG, "stop-ok");
        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.d(TAG, "stop()", e);
    }
    fireStopped();
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:20,代碼來源:AudioTrackPlayerImpl.java

示例2: release

@Override
public void release() {
    mCurrentState = PlayState.IDLE;
    if (writeWorkThread != null) {
        writeWorkThread.stopWrite();
    }
    try {
        Log.d(TAG, "release-PlayState:" + mAudioTrack.getPlayState());
        if (mAudioTrack != null && mAudioTrack.getPlayState() != AudioTrack.STATE_UNINITIALIZED) {
            mAudioTrack.pause();
            mAudioTrack.flush();
            mAudioTrack.stop();
            mAudioTrack.release();
            Log.d(TAG, "release-ok");
        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.d(TAG, "release()", e);
    }
    fireOnRelease();
    mediaPlayerListeners.clear();
    handlerMain.removeCallbacksAndMessages(null);
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:23,代碼來源:AudioTrackPlayerImpl.java

示例3: startPlayer

public boolean startPlayer(int streamType, int sampleRateInHz, int channelConfig, int audioFormat) {
    
    if (mIsPlayStarted) {
        Log.e(TAG, "Player already started !");
        return false;
    }
    
    mMinBufferSize = AudioTrack.getMinBufferSize(sampleRateInHz,channelConfig,audioFormat);
    if (mMinBufferSize == AudioTrack.ERROR_BAD_VALUE) {
        Log.e(TAG, "Invalid parameter !");
        return false;
    }
    Log.d(TAG , "getMinBufferSize = "+mMinBufferSize+" bytes !");
    
    mAudioTrack = new AudioTrack(streamType,sampleRateInHz,channelConfig,audioFormat,mMinBufferSize,DEFAULT_PLAY_MODE);
    if (mAudioTrack.getState() == AudioTrack.STATE_UNINITIALIZED) {
        Log.e(TAG, "AudioTrack initialize fail !");
        return false;
    }            
    
    mIsPlayStarted = true;
    
    Log.d(TAG, "Start audio player success !");
    
    return true;
}
 
開發者ID:ThinkKeep,項目名稱:EvilsLive,代碼行數:26,代碼來源:AudioPlayer.java

示例4: playStream

/**
 * Play the given InputStream.
 *
 * @param stream the stream
 */
public void playStream(InputStream stream) {
  try {
    byte[] data = convertStreamToByteArray(stream);
    if (data.length > 28) {
      sampleRate = readInt(data, 24);
    }
    int headSize = 44, metaDataSize = 48;
    int destPos = headSize + metaDataSize;
    int rawLength = data.length - destPos;
    byte[] d = new byte[rawLength];
    System.arraycopy(data, destPos, d, 0, rawLength);
    initPlayer();
    audioTrack.write(d, 0, d.length);
    stream.close();
    if (audioTrack != null && audioTrack.getState() != AudioTrack.STATE_UNINITIALIZED) {
      audioTrack.release();
    }
  } catch (IOException e2) {
    Log.e(TAG, e2.getMessage());
  }
}
 
開發者ID:watson-developer-cloud,項目名稱:android-sdk,代碼行數:26,代碼來源:StreamPlayer.java

示例5: playStream

/**
 * Play the given InputStream
 */
public void playStream(InputStream stream) {
  try {
    byte[] data = convertStreamToByteArray(stream);
    if (data.length > 28) {
      sampleRate = readInt(data, 24);
    }
    int headSize = 44, metaDataSize = 48;
    int destPos = headSize + metaDataSize;
    int rawLength = data.length - destPos;
    byte[] d = new byte[rawLength];
    System.arraycopy(data, destPos, d, 0, rawLength);
    initPlayer();
    audioTrack.write(d, 0, d.length);
    stream.close();
    if (audioTrack != null && audioTrack.getState() != AudioTrack.STATE_UNINITIALIZED) {
      audioTrack.release();
    }
  } catch (IOException e2) {
    Log.e(TAG, e2.getMessage());
  }
}
 
開發者ID:blumareks,項目名稱:2016EduHackathon_SanFrancisco,代碼行數:24,代碼來源:StreamPlayer.java

示例6: internal_stop_audio

protected void internal_stop_audio() {
	if (DEBUG) Log.v(TAG, "internal_stop_audio:");
   	if (mAudioTrack != null) {
   		if (mAudioTrack.getState() != AudioTrack.STATE_UNINITIALIZED)
   			mAudioTrack.stop();
   		mAudioTrack.release();
   		mAudioTrack = null;
   	}
	mAudioOutTempBuf = null;
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:10,代碼來源:MediaMoviePlayer.java


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