Code example for AudioTrack

Methods: getPlayStategetSampleRatesetPlaybackRate

0
        mAudioProcessors.clear();
        mAudioProcessors = null;
    } 
 
    public void setSamplingRate(float samplingRateScale) {
        if (mTrack != null && mTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) {
            mTrack.setPlaybackRate((int) ((samplingRateScale + 0.5f) * mTrack.getSampleRate()));
        } 
    } 
 
    private void initDecoder() throws InvalidMediaTypeException { 
        mMediaExtractor = new MediaExtractor();
        mMediaExtractor.setDataSource(mFile.getPath());
 
        int trackCount = mMediaExtractor.getTrackCount();
 
        if (trackCount == 0) throw new InvalidMediaTypeException("No track found.");
 
        MediaFormat audioFormat = mMediaExtractor.getTrackFormat(0);
        String mime = audioFormat.getString(MediaFormat.KEY_MIME);