How can I set the MediaPlayer sound volume according to ringtone volume?

I did this method, but doesn't work:

```
        MediaPlayer player = MediaPlayer.create(MyActivity.this, R.raw.sound);
        AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        int currentVolume = audio.getStreamVolume(AudioManager.RINGER_MODE_NORMAL);

        player.setVolume(currentVolume, currentVolume);

```