Repository: airbnb/lottie-ios
File: Sources/Public/Animation/LottieAnimationLayer.swift (Swift)

Code before:
        currentTime = from.frameTime
      case .end:
        currentTime = from.frameTime + from.durationFrameTime
      }
    }

    currentPlaybackMode = .paused(at: state)
  }

  @available(*, deprecated, renamed: "setPlaybackMode(_:completion:)", message: "Will be removed in a future major release.")
  open func play(
    _ playbackMode: LottiePlaybackMode,
    animationCompletionHandler: LottieCompletionBlock? = nil)
  {
    setPlaybackMode(playbackMode, completion: animationCompletionHandler)
  }

  /// Applies the given `LottiePlaybackMode` to this layer.
  /// - Parameter playbackMode: The playback mode to apply
  /// - Parameter completion: A closure that is called after
  ///   an animation triggered by this method completes.
  open func setPlaybackMode(
    _ playbackMode: LottiePlaybackMode,
    completion: LottieCompletionBlock? = nil)
  {
    switch playbackMode {
    case .paused(at: let state):
      pause(at: state)

    case .play(let mode):
      play(mode, completion: completion)

    case .progress(let progress):
      pause(at: .progress(progress))

    case .frame(let frame):
      pause(at: .frame(frame))

    case .time(let time):
      pause(at: .time(time))

    case .pause:
      pause(at: .currentFrame)

    case .fromProgress(let from, let to, let loopMode):
      play(.fromProgress(from, toProgress: to, loopMode: loopMode), completion: completion)

    case .fromFrame(let from, let to, let loopMode):
      play(.fromFrame(from, toFrame: to, loopMode: loopMode), completion: completion)

    case .fromMarker(let from, let to, let playEndMarkerFrame, let loopMode):

Review comment (suggestion):
Instead could this method be simplified to:

```swift
switch playbackMode {
case .playing(let playingMode):
  play(playbackMode, animationCompletionHandler: animationCompletionHandler)
case .paused(let pausedState):
  pause(at: pausedState, animationCompletionHandler: animationCompletionHandler)
}
```

Code after:
        currentTime = from.frameTime
      case .end:
        currentTime = from.frameTime + from.durationFrameTime
      }
    }

    currentPlaybackMode = .paused(at: state)
  }

  @available(*, deprecated, renamed: "setPlaybackMode(_:completion:)", message: "Will be removed in a future major release.")
  open func play(
    _ playbackMode: LottiePlaybackMode,
    animationCompletionHandler: LottieCompletionBlock? = nil)
  {
    setPlaybackMode(playbackMode, completion: animationCompletionHandler)
  }

  /// Applies the given `LottiePlaybackMode` to this layer.
  /// - Parameter playbackMode: The playback mode to apply
  /// - Parameter completion: A closure that is called after
  ///   an animation triggered by this method completes.
  open func setPlaybackMode(
    _ playbackMode: LottiePlaybackMode,
    completion: LottieCompletionBlock? = nil)
  {
    switch playbackMode {
    case .paused(at: let state):
      pause(at: state)

    case .playing(let mode):
      play(mode, completion: completion)

    case .progress(let progress):
      pause(at: .progress(progress))

    case .frame(let frame):
      pause(at: .frame(frame))

    case .time(let time):
      pause(at: .time(time))

    case .pause:
      pause(at: .currentFrame)

    case .fromProgress(let from, let to, let loopMode):
      play(.fromProgress(from, toProgress: to, loopMode: loopMode), completion: completion)

    case .fromFrame(let from, let to, let loopMode):
      play(.fromFrame(from, toFrame: to, loopMode: loopMode), completion: completion)

    case .fromMarker(let from, let to, let playEndMarkerFrame, let loopMode):