shts / StoriesProgressView

show horizontal progress like instagram stories.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ProgressBar not pausing if video is added

ksi3321 opened this issue · comments

Hello @shts , first of all thank you for the library. I have been running into this issue where if i add a video as the story content and long press on the screen, the progressbar starts it's animation while i am pressing and holding on the screen. when i let go of my finger , it again starts from the first and keeps progressing. If the content is image , it works perfectly fine. The progressbar pauses wherever it is on pressing the screen and resumes from the same place on releasing the finger.

This is the code for the onTouchListener:
`

private View.OnTouchListener onTouchListener = (v, event) -> {

    switch (event.getAction()) {

        case MotionEvent.ACTION_DOWN:

            pressTime = System.currentTimeMillis();

            viewBinding.stories.pause();

            return false;

        case MotionEvent.ACTION_UP:

            long now = System.currentTimeMillis();

            viewBinding.stories.resume();

            return limit < now - pressTime;
    }
    return false;
};`

This works completely fine for image story. I modified this for the video:

`

private View.OnTouchListener onTouchListener = (v, event) -> {

    switch (event.getAction()) {

        case MotionEvent.ACTION_DOWN:

            pressTime = System.currentTimeMillis();

            if (playable != null) {

               viewBinding.stories.pause();
                playable.pause();

            } else {

                viewBinding.stories.pause();
            }

            return false;
        case MotionEvent.ACTION_UP:
            long now = System.currentTimeMillis();
            if (playable != null) {

                viewBinding.stories.resume();
                playable.play();

            } else {

                viewBinding.stories.resume();
            }
            return limit < now - pressTime;
    }
    return false;
};`

When I do this , the video is paused. But the progressbar keeps animating while holding and pressing the screen and when i let go it again starts from the beginning and goes all the way to the end. I am not sure why this is happening. Please see the video here : https://imgur.com/a/MGUPD2t

The video library i use is Exoplayer 2.

@shts I would like to get some help on this since I am using this library for my application.

@shts I would like to get some help on this since I am using this library for my application.

Hi, how did you implement video in that library?
Can you help-me? could you help me with some code? I've only been able to deploy images so far

@jonataslaw I have already posted the sample implementation of my code with audio and video. The video player I have used is Exoplayer

@maximus9600 @jonataslaw hello. Did you find any solution for this case? I have the same issue

@jonataslaw I have already posted the sample implementation of my code with audio and video. The video player I have used is Exoplayer

link ???

Hey @maximus9600 If this still an issue, call the pause/resume method as follows:

Handler().post { storiesProgressView.pause() }

And

Handler().post { storiesProgressView.resume() }

Those are in Kotlin though but i trust you'll understand.

commented

Hey @maximus9600 If this still an issue, call the pause/resume method as follows:

Handler().post { storiesProgressView.pause() }

And

Handler().post { storiesProgressView.resume() }

Those are in Kotlin though but i trust you'll understand.

You can also use view.post() to update UI