Android学习笔记(3)——使用AudioTrack进行音频播放
android.media.AudioTrack.AudioTrack(intstreamType, int sampleRateInHz, int channelConfig, int audioFormat,int bufferSizeInBytes, int mode) throws IllegalArgumentException
public AudioTrack (intstreamType, int sampleRateInHz, int channelConfig, int audioFormat,int bufferSizeInBytes, int mode)
Since:
API Level3
Class constructor.
Parameters
streamType | the type of the audio stream. See STREAM_VOICE_CALL , STREAM_SYSTEM ,STREAM_RING ,STREAM_MUSIC and STREAM_ALARM |
---|---|
sampleRateInHz | the sample rate expressed in Hertz. Examples of rates are (butnot limited to) 44100, 22050 and 11025. |
channelConfig | describes the configuration of the audio channels. SeeCHANNEL_OUT_MONO and CHANNEL_OUT_STEREO |
audioFormat | the format in which the audio data is represented. SeeENCODING_PCM_16BIT and ENCODING_PCM_8BIT |
bufferSizeInBytes | the total size (in bytes) of the buffer where audio data isread from for playback. If using the AudioTrack in streaming mode,you can write data into this buffer in smaller chunks than thissize. If using the AudioTrack in static mode, this is the maximumsize of the sound that will be played for this instance. SeegetMinBufferSize(int, int, int) to determine the minimumrequired buffer size for the successful creation of an AudioTrackinstance in streaming mode. Using values smaller thangetMinBufferSize() will result in an initialization failure. |
mode | streaming or static buffer. See MODE_STATIC and MODE_STREAM |
Throws
IllegalArgumentException |
---|