Fresco: Animated Gif Pause/Unpause

Created on 4 Nov 2016  路  15Comments  路  Source: facebook/fresco

Just wanted to be sure, is this function not supported or I overlooked it?

Thank you.

question

Most helpful comment

Sorry, there's no particular timeline but we'll keep you updated.

All 15 comments

Hi @Wilson13
at the moment we don't support the pause but we're working on it
Thanks

Hi @massimocarli

I see, looking forward to that function.

Thanks!

Hi @Wilson13
On this subject, I have some ideas, this is my code

private Animatable mAnimatable;
DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setUri(Uri.parse(url))
                .setAutoPlayAnimations(false)
                .setControllerListener(new BaseControllerListener<ImageInfo>(){
                    @Override
                    public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                        if (animatable!=null){
                            mAnimatable=animatable;
                        }
                    }
                })
                .build();
simpleDraweeView.setController(controller);

Then I use a button to control gif play or pause

btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mAnimatable!=null){
                    if (isStart){
                        mAnimatable.start();
                        isStart=false;
                    }else {
                        mAnimatable.stop();
                        isStart=true;
                    }

                }
            }
        });

The issue with @liukangqi2015 's solution is that it doesn't pause but reset the animation. There is currently not a simple way to resume an ongoing animation without resetting. Our new animation architecture will support this though. We'll keep you updated when it's ready.

Looking forward to the update

Hi @liukangqi2015,

@oprisnik was absolutely correct, and that was the issue I was facing. I couldn't pause then resume from where the animation has temporary stopped. It could only be stopped and restarted.

@oprisnik Looking forward to the update, thanks for the hard work.

@liukangqi2015 Thanks for your effort though =)

@Wilson13 ,sorry,on your question, I seem to understand the wrong.

@oprisnik looking forward for new Animation architecture

@oprisnik is there a particular timeline for adding in the animation architecture? We're looking forward to it :smile:

Sorry, there's no particular timeline but we'll keep you updated.

Hey @oprisnik, any update on this?

The new architecture is out and I believe we recently made a change that should allow this to work. I'll check.

Is there a better way to stop or restart the GIF?

Hi, Any progress on it?

This has been fixed with 22f6426cf975a7f43ce9911895dede11e3eb0143, thanks to @yoavbeeri

You can just stop() and start() the animation now.

Was this page helpful?
0 / 5 - 0 ratings