1

I'm working on AndroidTv where I'm using the standard seekBar for playback.

This is how I'm using the RxSeekBar

RxSeekBar.changeEvents(seekBar)
            .debounce(SEEKBAR_DEBOUNCE_TIME, TimeUnit.MILLISECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<SeekBarChangeEvent>() {
                @Override
                public void onSubscribe(Disposable disposable) {
                    compositeDisposable.add(disposable);
                }

                @Override
                public void onNext(SeekBarChangeEvent seekBarChangeEvent) {
                    if (seekBarChangeEvent instanceof SeekBarProgressChangeEvent) {
                        if (seekBar.hasFocus()) {
                            DebugLog.d(TAG, "(PROGRESS) SeekBarProgressChangeEvent");
                            seekBarSeekProgress = seekBarChangeEvent.getView().getProgress();
                            onSeek();
                        }
                    }
                }

                @Override
                public void onError(Throwable e) {
                    DebugLog.d(TAG, "RxSeek error - " + e.getMessage());
                }

                @Override
                public void onComplete() {

                }
            });

Basically, I want to update things after the debounce timeout. This works fine 7/10 times but sometimes onNext is called prematurely and things go off hand.

Am I doing something wrong here?

Veeresh Charantimath
  • 4,641
  • 5
  • 27
  • 36
  • Try doing the operation in onComplete – coroutineDispatcher Apr 16 '19 at 07:11
  • onComplete is never called, only onNext is called every debounce timeout – Veeresh Charantimath Apr 16 '19 at 07:16
  • Also, I keep updating my seekBar every 1 sec for music playback – Veeresh Charantimath Apr 16 '19 at 07:16
  • What do you mean by "prematurely" - before the debounce period has been met, if so that would suggest an issue with RxJava debounce, but unlikely? The probable cause is your debounce is not long enough, hence why sometimes it works, and others it doesn't -it should be at least higher than the update interval period of 1 second, otherwise you'll end up in a continuous cycle of events as you update the seek bar manually.. – Mark Apr 18 '19 at 15:57

0 Answers0