Pre loader

Tag: mediaplayer

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1 vote
0 answers
4k views

Hi
I have a chart from a sound.
In xiaomi phones when resume chart after pause it, my line chart faces the severe lag.
In other phones my chart work well.
what should I do?
phone is (Xiaomi mi a3)

private void resume() {

    forceRunInPauseMode = true;
    mediaPlayer.seekTo(currentTime);
    mediaPlayer.start();
    completedState = false;
    pauseState = false;
    updateChart();
}



private void updateChart() {
    schedule = scheduledExecutorService.scheduleWithFixedDelay(() -> {
        if (mediaPlayer.isPlaying() || forceRunInPauseMode){
            UpdateSuspender.using(binding.sciChart, mRunnable);
        }
    }, 0, TIME_INTERVAL, TimeUnit.MILLISECONDS);

}

private Runnable mRunnable = new Runnable() {
    @Override
    public void run() {
        forceRunInPauseMode = false;


        currentTime = mediaPlayer.getCurrentPosition();
        currentRange = currentTime * 2;
        getActivity().runOnUiThread(()->binding.tvCurrentDuration.setText(MiliToTimeConverter.milliToTime(currentTime)));

        if (currentRange < 0)
            currentRange = 0;
        else if (currentRange > xDoubleArray.length - 1)
            currentRange = xDoubleArray.length - 1;

        if (!drawed) {
            DoubleValues xValues = new DoubleValues(Arrays.copyOfRange(xDoubleArray, 0, xDoubleArray.length-1));
            DoubleValues yValues = new DoubleValues(Arrays.copyOfRange(yDoubleArray, 0, yDoubleArray.length-1));
            DoubleSeries doubleSeries = new DoubleSeries(xValues, yValues);
            lineData.append(doubleSeries.getxValues(), doubleSeries.getyValues());
            drawed = true;
        }
        xVisibleRange.setMinMax((double) (currentRange - visibleInterval / 2), (double) (currentRange + visibleInterval / 2));
    }
};
Showing 1 result

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies