安卓:MediaPlayer setVolume 函数 [英] Android: MediaPlayer setVolume function

查看:43
本文介绍了安卓:MediaPlayer setVolume 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于参数设置什么使播放器无声和全声

about the params Set what to make the player no sound and full sound

谢谢

推荐答案

这个功能真的很棒.多亏了它,您可以创建包含任意步数的音量标尺!

This function is actualy wonderful. Thanks to it you can create a volume scale with any number of steps!

假设您需要 50 个步骤:

Let's assume you want 50 steps:

int maxVolume = 50;

然后将 setVolume 设置为此范围 (0-49) 中的任何值,您可以这样做:

Then to set setVolume to any value in this range (0-49) you do this:

float log1=(float)(Math.log(maxVolume-currVolume)/Math.log(maxVolume));
yourMediaPlayer.setVolume(log1,log1); //set volume takes two paramater

又好又容易!并且不要使用 AudioManager 设置音量!它会导致许多副作用,例如禁用静音模式,这会让您的用户发疯!

Nice and easy! And DON'T use AudioManager to set volume! It will cause many side effects such as disabling silent mode, which will make your users mad!

这篇关于安卓:MediaPlayer setVolume 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆