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

Code before:
    guard animation?.markerMap?[markerToPlay] != nil else {
      play(markers: followingMarkers, completion: completion)
      return
    }

    play(marker: markerToPlay, loopMode: .playOnce, completion: { [weak self] completed in
      // If the completion handler is called with `completed: false` (which typically means
      // that another animation was played by calling some `play` method),
      // we should cancel the marker sequence and not play the next marker.
      guard completed, let self = self else {
        completion?(false)
        return
      }

      if followingMarkers.isEmpty {
        // If we don't have any more markers to play, then the marker sequence has completed.
        completion?(completed)
      } else {
        self.play(markers: followingMarkers, completion: completion)
      }
    })
  }

  /// Pauses the animation at a given marker and position
  open func pause(at marker: String, position: LottiePlaybackMode.MarkerPosition)
  {
    guard let from = animation?.markerMap?[marker] else {
      return
    }

    defer {
      currentPlaybackMode = .pausedAtMarker(marker, position: position)
    }

    switch position {
    case .start:
      currentTime = from.frameTime
    case .end:
      currentTime = from.frameTime + from.durationFrameTime
    }
  }

  /// Stops the animation and resets the layer to its start frame.
  ///
  /// The completion closure will be called with `false`
  open func stop() {
    removeCurrentAnimation()
    currentFrame = 0
  }

  /// Pauses the animation in its current state.

Review comment (suggestion):
```suggestion
  open func pause(at marker: String, position: LottiePlaybackMode.MarkerPosition) {
```

Code after:
    guard animation?.markerMap?[markerToPlay] != nil else {
      play(markers: followingMarkers, completion: completion)
      return
    }

    play(marker: markerToPlay, loopMode: .playOnce, completion: { [weak self] completed in
      // If the completion handler is called with `completed: false` (which typically means
      // that another animation was played by calling some `play` method),
      // we should cancel the marker sequence and not play the next marker.
      guard completed, let self = self else {
        completion?(false)
        return
      }

      if followingMarkers.isEmpty {
        // If we don't have any more markers to play, then the marker sequence has completed.
        completion?(completed)
      } else {
        self.play(markers: followingMarkers, completion: completion)
      }
    })
  }

  /// Stops the animation and resets the layer to its start frame.
  ///
  /// The completion closure will be called with `false`
  open func stop() {
    removeCurrentAnimation()
    currentFrame = 0
  }

  /// Pauses the animation in its current state.
  ///
  /// The completion closure will be called with `false`
  open func pause() {
    pause(at: .currentFrame)
  }

  /// Pauses the animation at a given state.
  open func pause(at state: LottiePlaybackMode.PausedState) {
    switch state {
    case .currentFrame:
      removeCurrentAnimation()

    case .progress(let animationProgressTime):
      currentProgress = animationProgressTime

    case .frame(let animationFrameTime):
      currentFrame = animationFrameTime
    case .time(let timeInterval):
      currentTime = timeInterval