AKClipMerger

open class AKClipMerger: NSObject

AKClipMerger merges new clips into an existing array of validated clips and returns a new array of validated clips including the new clip.

Validation rules:

  • The clip itself must be valid as defined by the clip’s isValid function.
  • The clips in the array must not overlap each other (clip.time + clip.duration <= nextClip.time).

The strategy used when a new clip overlaps an existing clip is last-in precedence. Existing clips will shortened, split, or removed in order to make room for the new clip. Since clips can be split or removed, merging a clip may result in the clip count decreasing when a clip is merged, or increasing by more than 1. This behavior requires that the clip merger create clips, so to facilitate this need it uses a delegate. When a clip is to be shortened, it is removed from the existing clips, and a new clip is created using the delegate’s newClip function. When a clip is to be split, the original is removed and newClip will be called twice. When a clip is removed, the delegate’s clipWillBeRemoved function will be called (if implemented).

  • The delegate used for clip editing and creation.

    Declaration

    Swift

    open weak var mergeDelegate: ClipMergeDelegate?
  • Creates a validated array of clips with the new clip merged into an array of validated clips.

    Declaration

    Swift

    @objc open func merge(clip: AKClip, clips: [AKClip]) -> [AKClip]

    Parameters

    clip

    The clip to be merged

    clips

    A validated clip array.

    Return Value

    A validated array of clips containing the new clip merged with clips.

  • Validate an array of clips

    Throws

    ClipMergeError if clips are not valid.

    Declaration

    Swift

    open class func validateClips(_ clips: [AKClip]) throws -> [AKClip]

    Parameters

    clips

    An array of clips to be validated.

    Return Value

    The input array un-altered if valid.