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