当前位置: 首页>>代码示例>>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;未经允许,请勿转载。