private void setValume(float percent)
{
if (mVolume == -1)
{
mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
if (mVolume < 0)
{
mVolume = 0;
}
mOperationBg.setImageResource(R.drawable.video_volumn_bg);
mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
}
int index = (int) ((percent * mMaxVolume) + mVolume);
if (index > mMaxVolume)
{
index = mMaxVolume;// 最大音量
}
else if (index < 0)
{
index = 0;// 静音
}
// 变更声音
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
// 变更进度条
ViewGroup.LayoutParams lp = mOperationPercent.getLayoutParams();
lp.width = findViewById(R.id.operation_full).getLayoutParams().width * index /
mMaxVolume;
mOperationPercent.setLayoutParams(lp);
}