android用代码设置音量值?

android播放背景音乐时以最大音量值播放,应该怎么设置媒体音量值?

mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, Val, AudioManager.FLAG_PLAY_SOUND);//设置值为Val
max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC );//获取最大值
current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC );//获取当前值

mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, Val, AudioManager.FLAG_PLAY_SOUND);//设置值为Val