要更改exoplayer的速度,我们使用player.setPlaybackParameters
这会改变速度,但是我们如何仅在特定持续时间内设置速度
我使用的代码是
playerTimer.setCallback(new PlayerTimer.Callback() {
@Override
public void onTick(long timeMillis) {
if (player != null) {
long position = player.getCurrentPosition();
long duration = player.getDuration();
speeder(position);
}
}
});
和
public void speeder(long pos) {
if (player.getCurrentWindowIndex() == 1) {
if (pos >= 100000) &&
pos <= 200000){
PlaybackParameters playbackParameters = new PlaybackParameters(
2.0f, 1.0f);
player.setPlaybackParameters(playbackParameters);
}
else if (pos <= 100000) &&
pos >= 200000)
{
PlaybackParameters playbackParameters1 = new PlaybackParameters(
1.0f, 1.0f);
player.setPlaybackParameters(playbackParameters1);
}
}
}
但是速度在100000到200000之间时不会改变
答案 0 :(得分:0)
注意:
else if (pos <= 100000) && pos >= 200000) {
//the value of pos cannot be smaller than 100000 and bigger than 200000 Simultaneously
}
因此条件始终为false