Android SeekBar talkback talking too much

(Android). On the music player, you refresh the search bar 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())); ... 

However, if the focus is in the search bar, Talkback support constantly and non-stop provides feedback for progress. How to “seek control of 25%,” “seek control of 25%,” “seek control of 25%,” “seek control of 26%,” “seek control of 26%,” “seek control of 27%”

I am missing sth, but I could not solve the problem. I set the contentDescription to a value other than @null. But then he reads the description of the contents this time without stopping.

In the Spotify client that I checked, it reads the progress as “xx percent” only once. Despite maintaining focus on the search bar.

When I change the accuracy for 1 or 100, you lose accuracy in the search bar. There seem to be several parts to the song. You play one or the other by scrolling the arrow.

Has anyone experienced this like that? I could not find anything in google docs, network stack or anywhere else.

+1
source share
1 answer

I had a problem, and I found that SeekBar reads the percentage on every update.

It helped that I update SeekBar only when the percentage changes, but still maintains high accuracy (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 initialized to -1.

Please note that this solution is not the same as Spotify.
Spotify overrides the message announced by the system when selecting SeekBar.
This has the following 2 effects:

  • Updates can be made as often as you want, without repeating the percentage.
  • When the percentage changes when you select SeekBar, nothing is announced.

Point 2 can make me a flaw depending on what you want to achieve.

0
source

All Articles