Hi everyone, I need to modify the volume of an AudioTrack, while it is
playing a sound in streaming mode.
I have something like this:

minBufSize=AudioTrack.getMinBufferSize(11025,
AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT);
                fSound=new AudioTrack(
                        AudioManager.STREAM_MUSIC,
                        11025,
                        AudioFormat.CHANNEL_OUT_STEREO,
                        AudioFormat.ENCODING_PCM_16BIT,
                        minBufSize,
                        AudioTrack.MODE_STREAM
                        );

        
sample=this.getApplicationContext().getResources().openRawResource(R.raw.longfart);
                b=new byte[minBufSize];
                fSound.play();

fSound.setPlaybackRate(11025/2 + 11025*(yPos+187)/(2*187));
                                        fSound.setStereoVolume( volume, volume);
                                        try {
                                                c=sample.read(b, 0, b.length);
                                        } catch (IOException e1) {
                                        }
                                        while(c!=-1){
                                                fSound.write(b, 0, c);
                                                try {
                                                        c=sample.read(b, 0, 
b.length);
                                                } catch (IOException e) {

                                                }
                                        }


This works ok and plays the whole "song" (it's just a few seconds).
What I want to do is allow the user to change the volume while the
stream is being played. Can it be done?
Thanks
Simone

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to