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

Play the count of plays of the GIF to the count of plays of the GIF itself. #1863

Closed
JerryLiust opened this issue Sep 11, 2023 · 4 comments
Closed
Labels
enhancement New feature or request help wanted Issues that are up for grabs + are good candidates for community PRs

Comments

@JerryLiust
Copy link

JerryLiust commented Sep 11, 2023

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
I want to play the count of plays of the GIF to the count of plays of the GIF itself.
For example, the built-in count of plays of GIF is 3, and I want to play the corresponding count, and I don't want to set a repeatCount by ImageRequest, but if I don't set it, the default repeatCount will be REPEAT_INFINITE, this is not what I want.

Describe the solution you'd like
A clear and concise description of what you want to happen.
I want to play the built-in count of GIF without manually set a fixed count of playback times.

Additional context
Add any other context or screenshots about the feature request here.
image
The baseDrawable.repeatCount is what I want, but it will be reassigned to options.parameters.repeatCount() ?: REPEAT_INFINITE, how should I play the repeatCount of baseDrawale automatically?

@JerryLiust JerryLiust added the enhancement New feature or request label Sep 11, 2023
@colinrtwhite
Copy link
Member

We should definitely support this. I don't think we can change the existing default behaviour unfortunately, but we could probably introduce a special constant that triggers this behaviour.

@JerryLiust
Copy link
Author

Thanks for your reply, I'm looking forward to your new version of coil to support this.

@colinrtwhite colinrtwhite added the help wanted Issues that are up for grabs + are good candidates for community PRs label Feb 1, 2024
@tgyuuAn
Copy link
Contributor

tgyuuAn commented Oct 27, 2024

@colinrtwhite

how about defining a new chaining method in the ImageRequest Builder to solve this?

For example:

fun ImageRequest.applyRepeatCountFromData(): ImageRequest {
    val repeatCount = getRepeatCountFromMetadata(data) ?: return this

    return this.newBuilder()
        .repeatCount(repeatCount)
        .build()
}

Since the loop count in GIF metadata can be null, this method would attempt parsing when called. If parsing fails or returns a null value, the chaining wouldn’t proceed, and the default infinite loop would apply.

(Likewise for webp and heif)




It seems like fixing the decoder will take a lot of resources.

It seems like the solution to Image Request might be relatively simple.

What do you think?!?!?!

@colinrtwhite
Copy link
Member

Resolved by #2654. Will be released in 3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Issues that are up for grabs + are good candidates for community PRs
Projects
None yet
Development

No branches or pull requests

3 participants