安卓:MediaPlayer的setVolume功能 [英] Android: MediaPlayer setVolume function

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

问题描述

有关PARAMS 设置了什么让玩家无声音和饱满的声音

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

感谢

推荐答案

这个功能是actualy精彩。多亏了它,你可以创建一个卷的规模与任何数量的步骤!

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(1-log1);

尼斯和容易!并且没有使用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天全站免登陆