Rewind, Pause and Forward GIFs

Viewed 799

I am currently using the Glide library to play GIFs as follows.

Glide.with(this).load(gifUrl).into(ImageView);

This works fine but I would like the user to have the option to rewind, pause and forward the GIF. I am thinking just buttons that rewind/forward 10 seconds and another button to pause. It won't be possible for me to use mp4 videos, and thus a video playing library, since the files that I am using are GIFs. Is there any way I can do this while still using Glide or will I have to use another library?

Any help is greatly appreciated.

1 Answers

Your best bet is probably to convert your gif into an mp4 video using a third party library and then use native android functions to forward, pause, and rewind that mp4.

I'm sure there is an API that does this, you just need to look. Maybe try looking here https://android-arsenal.com/tag/193. It would be much harder to forward and rewind a gif, so you need to first convert.

An example of how to create your "forward 10 seconds" button. seekForwardTime would be 10,000 ms.

 btnForward.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // get current song position
            int currentPosition = mp.getCurrentPosition();
            // check if seekForward time is lesser than song duration
            if (currentPosition + seekForwardTime <= mp.getDuration()) {
                // forward song
                mp.seekTo(currentPosition + seekForwardTime);
            } else {
                // forward to end position
                mp.seekTo(mp.getDuration());
            }
            return false;
        }
    });
Related