首页 > 移动平台 > 详细

ios音量线性下降

时间:2015-05-28 02:18:08      阅读:288      评论:0      收藏:0      [点我收藏+]

直接上代码吧

?

//second 几秒内下降为0
- (void)reduceVolume:(int)second {
    KGVoicePlayer *player = [KGVoicePlayer defaultPlayer];
    
    if (!_flag) {
        _tempVolume = player.volume;
        _flag = YES;
    }

    // 经测试-45db已经可以当作静音
    player.volume = dBToLinear(-4.5*(10 - second));
}

static const float M_LN = 2.30258509299404568402; /* natural log of 10 */
static inline float dBToLinear( int dB )
{
    return exp( ( dB ) * M_LN * 0.05 );
}

?

ios音量线性下降

原文:http://bewithme.iteye.com/blog/2214774

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!