Search code examples
androidandroid-mediaplayer

Android MediaPlayer setVolume not working properly


when i use the function setVolume(left,right) the volume of the song is affected just by left volume, right can be whatever number, mp just does not care. The volume changes correctly on both ears, just following the left one.

here are pieces of code

mp = MediaPlayer.create(ZenActivity.appContext, resID);
mp.setLooping(true);
mp.setVolume(stream_volL, stream_volR);
mp.start();

vol_downR.setOnTouchListener(new Button.OnTouchListener() {
            private Handler mHandler;
            Runnable mAction = new Runnable() {
                @Override public void run() {
                    stream_volR= Math.max(0f,stream_volR-0.0025f);
                    mp.setVolume(stream_volL,stream_volR);
                    mHandler.postDelayed(this, 50);
                }
            };

i looked at all(?) the posts about setVolume but no one seems to have my same problem, either the function does not work completely or they have other issues; in any way their solutions did not work for me


Solution

  • i solved it, the files that i was trying to play were mono, so i used audacity and make them stereo by duplicating the track