EspoirX / StarrySky

🔥A Powerful and Streamline MusicLibrary(一个丰富的音乐播放封装库,支持多种音频格式,完美解决你的问题。)
https://github.com/EspoirX/StarrySky
MIT License
1.39k stars 209 forks source link

大佬求助 #183

Closed Zpsgithub closed 3 years ago

Zpsgithub commented 3 years ago
/**
 * 指定语速,通过此方法可配置任意倍速,注意结果要大于0
 *
 * @param refer    refer 是否已当前速度为基数
 * @param multiple multiple 倍率
 */
fun onDerailleur(refer: Boolean, multiple: Float). 设置其中一个倍速后 就切换不回来了  如何切换播放速度 0.7f~2.5f 
EspoirX commented 3 years ago
                seekBar.max = 250 //最大2.5倍(放大100倍比较好算)
                seekBar.progress = StarrySky.with().getPlaybackSpeed().toInt() * 100 //当前速度
                seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
                    override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                        //调速
                        if (progress >= 70) { //最小 0.7
                            StarrySky.with().onDerailleur(false, progress.toFloat() / 100)
                            Log.i("TEST", "当前速度:$progress %")
                        }
                    }

                    override fun onStartTrackingTouch(seekBar: SeekBar) {}
                    override fun onStopTrackingTouch(seekBar: SeekBar) {}
                })

差不多这样,自己改改就好