(Android)在音乐播放器上,您可以按预期的方式更新搜索栏:
(Android) On a music player, you update the seekbar as expected with this:
PRECISION_SEEKBAR = 100000; ((SeekBar) findViewById(R.id.seekBar2)).setMax(PRECISION_SEEKBAR); timerSeekBarUpdate.scheduleAtFixedRate(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { final SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar); @Override public void run() { if (control == null || player == null) { cancel(); return; } seekBar.setProgress((int) (player.getCurrentPosition() * PRECISION_SEEKBAR / player.getDuration())); ...但是,如果焦点在搜寻栏上,则对讲稳定且不间断提供进度反馈,例如寻求控制25%,寻求控制25%,寻求控制25%,寻求控制26%,寻求控制26%,寻求控制27%
However, if the focus is on the seek bar, talkback steadily and nonstop gives feedback for the progress. Like "seek control 25%", "seek control 25%", "seek control 25%", "seek control 26%", "seek control 26%", "seek control 27%"
我遗漏了某事,但无法解决问题。 @null以外的contentDescription。
I'm missing sth but couldnot solve the problem. I have set the contentDescription to other than @null. But then it reads the content description this time without stopping.
在Spotify客户端上,我检查了一下,它仅将进度读取为 xx%。
On Spotify client, I checked, it reads the progress as "xx percent" just once. Despite saving the focus on the seekbar.
当我将精度编辑为1或100时,您会丢失搜索栏上的精度。歌曲中似乎有几个部分。您可以通过滑动搜索栏来玩一个或另一个。
When I edit the precision for 1 or 100, then you lose the precision on the seekbar. It looks like there are a few parts in the song. You either play one or another by swiping on the seekbar.
有人经历过这样的事情吗?我在Google文档,堆栈网络或其他地方找不到任何内容。
Has anybody experienced sth like this? I couldn't find anything on google docs, stack network or somewhere else.
推荐答案我遇到了问题,发现SeekBar读取了
I had the problem and found that SeekBar reads the percentage on every update.
这很有帮助,我只在百分比变化时才更新SeekBar,但仍然保持较高的精度(以我的情况为单位)。
It helped, that I update the SeekBar only when the percentage changes but still keep a high precision (in my case in ms).
@Override public void updateSeekBar(final int currentPosInMillis, final int durationInMillis) { long progressPercent = calculatePercent(currentPosInMillis, durationInMillis); if (progressPercent != previousProgressPercent) { seekBar.setMax(durationInMillis); seekBar.setProgress(currentPosInMillis); } previousProgressPercent = progressPercent; } private int calculatePercent(int currentPosInMillis, int durationInMillis) { if(durationInMillis == 0) { return 0; } return (int) (((float)currentPosInMillis / durationInMillis) * 100); }previousProgressPercent 已初始化到-1。
请注意,此解决方案与Spotify的解决方案不同。 Spotify会在系统提示时覆盖系统宣布的消息。 SeekBar被选中。 这具有以下2种效果:
Please note that this solution is not the same as Spotify does it. Spotify overrides the message announced by the system when the SeekBar gets selected. This has following 2 effects:
- 可以根据需要进行多次更新,而无需重复蜂鸣百分比
- 当选择SeekBar时百分比发生变化时,则什么都不会宣布
第二点可能是我的缺点,具体取决于您要实现的目标。
Point 2 might me a drawback depending on what you want to achieve.
更多推荐
Android SeekBar对讲,说话太多
发布评论