本文整理匯總了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();
}
示例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);
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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;
}