SDWebImageSwiftUI icon indicating copy to clipboard operation
SDWebImageSwiftUI copied to clipboard

Feature request: access to ImagePlayer.animationFrameHandler

Open Ccapton opened this issue 3 months ago • 2 comments

SDWebImageSwiftUI

Currently ImagePlayer does not expose the animationFrameHandler. It would be very helpful if we can pass in a custom animationFrameHandler when using ImagePlayer.

Use cases:

  • Track the current frame index during animation playback
  • Implement custom progress UI or analytics
  • Detect when the animation reaches the last frame (playback complete)

Ccapton avatar Sep 02 '25 13:09 Ccapton

We wish to pass a custom animationFrameHandler through WebImage.

For example, it would be very useful if we could attach a handler for playback progress:

extension WebImage {
    /// Example API to illustrate the idea
    public func playProgress(_ handler: @escaping (_ currentIndex: Int, _ isLastIndex: Bool) -> Void) -> WebImage {
        // ...
    }
}

Ccapton avatar Sep 02 '25 13:09 Ccapton

Seems it is easy if we expose SDImagePlayer (from SDWebImage Core) directly. You can grab this object and do custom animation by your own.

Your API sounds OK as well. Need some decision

dreampiggy avatar Sep 03 '25 03:09 dreampiggy