Coder Social home page Coder Social logo

Comments (7)

fouadkada avatar fouadkada commented on May 28, 2024 3

i am trying to use the project to display a gif as a splash screen, it would be nice to get the duration of the animation to start a new viewcontroller after a specific duration

from gifu.

kaishin avatar kaishin commented on May 28, 2024

No it is not. It could be something that the API exposes though. What you need that info for?

from gifu.

kaishin avatar kaishin commented on May 28, 2024

Yes, that is not unreasonable.

from gifu.

fouadkada avatar fouadkada commented on May 28, 2024

i am following the same approach on the android version of my project and for that i am using this project https://github.com/koral--/android-gif-drawable
and that project exposes this set of APIs

stop() - stops the animation, can be called from any thread
start() - starts the animation, can be called from any thread
isRunning() - returns whether animation is currently running or not
reset() - rewinds the animation, does not restart stopped one
setSpeed(float factor) - sets new animation speed factor, eg. passing 2.0f will double the animation speed
seekTo(int position) - seeks animation (within current loop) to given position (in milliseconds)
getDuration() - returns duration of one loop of the animation
getCurrentPosition()

they also expose an event listener that is triggered on animation completion which can be used to start a new controller
this is the equivalent in android

gifDrawable.addAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationCompleted() {
                    Log.d(TAG, "splash screen animation complete...starting activity");
                    if (gifDrawable.canPause()) {
                        gifDrawable.pause();
                    }
                    Intent i = new Intent(SplashScreen.this, MainActivity.class);
                    startActivity(i);
                }
            });

it would be nice to have something similar

from gifu.

kaishin avatar kaishin commented on May 28, 2024

Thanks for sharing this @fouadkada. I had thought about adding some of these and this is a good reference. I'd happily welcome PRs as well.

from gifu.

cprovatas avatar cprovatas commented on May 28, 2024

+1 on this as well. I'm working in a project that is dependent on showing a new view controller when the gif image has finished. It would be great for this to be dynamic instead having to manually find out the duration of the gif file.

from gifu.

kaishin avatar kaishin commented on May 28, 2024

This can be done using GIFAnimatable.gifLoopDuration starting https://github.com/kaishin/Gifu/releases/tag/v3.0.0 😉 It used to be there before but didn't work properly if called immediately after calling any of the animate() functions.

from gifu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.