Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProgressBar not pausing if video is added #20

Open
ksi3321 opened this issue Feb 14, 2019 · 7 comments
Open

ProgressBar not pausing if video is added #20

ksi3321 opened this issue Feb 14, 2019 · 7 comments

Comments

@ksi3321
Copy link

ksi3321 commented Feb 14, 2019

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.

@ksi3321
Copy link
Author

ksi3321 commented Feb 19, 2019

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

@jonataslaw
Copy link

@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

@ksi3321
Copy link
Author

ksi3321 commented Mar 12, 2019

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

@elkasvirElka
Copy link

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

@AManan806
Copy link

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

link ???

@ahmedmolawale
Copy 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.

@samir-gawas
Copy 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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants