ijkplayer在miui安卓9.0系统上调节倍速失效

该问题在官方github的issues中有人给了出解决方案https://github.com/bilibili/ijkplayer/issues/4569,但是很多小伙伴还是没能正确处理,我也是走了不少弯路,但最总得以解决,记录如下
错误示例1如下:

boolean setSpeed(float speed){
    ijkplayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "soundtouch", 1);
    ijkplayer.setSpeed(speed);
    return true;
}

错误示例2如下:

if (!url.trim().equals(this.url.trim())) {
  try {
    ijkplayer.release();
   } catch (Exception e) {
     e.printStackTrace();
   }
  ijkplayer = new IjkMediaPlayer();
  ijkplayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "soundtouch", 1);
  ijkplayer.reset();
  ijkplayer.setDataSource(url);
  ijkplayer.prepareAsync();
}

正确示例代码如下:

if (!url.trim().equals(this.url.trim())) {
  try {
    ijkplayer.release();
   } catch (Exception e) {
     e.printStackTrace();
   }
  ijkplayer = new IjkMediaPlayer();
  ijkplayer.reset();
  ijkplayer.setDataSource(url);
  ijkplayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "soundtouch", 1);
  ijkplayer.prepareAsync();
}

你可能感兴趣的:(ijkplayer在miui安卓9.0系统上调节倍速失效)