AKClipPlayer

open class AKClipPlayer: AKNode, AKTiming

Schedules multiple audio files to be played in a sequence.

  • The underlying player node

    Declaration

    Swift

    open let playerNode = AVAudioPlayerNode()
  • Sets the current time in seconds.

    Declaration

    Swift

    open func setTime(_ time: Double)
  • Time in seconds at a given audio time

    Declaration

    Swift

    open func time(atAudioTime audioTime: AVAudioTime?) -> Double

    Parameters

    audioTime

    A time in the audio render context.

    Return Value

    Time in seconds in the context of the player’s timeline.

  • Audio time for a given time.

    Declaration

    Swift

    open func audioTime(atTime time: Double) -> AVAudioTime?

    Parameters

    time

    Time in seconds in the context of the player’s timeline.

    Return Value

    A time in the audio render context.

  • Current time of the player in seconds.

    Declaration

    Swift

    open var currentTime: Double
  • True is play, flase if not.

    Declaration

    Swift

    open var isPlaying: Bool
  • Sets the clips sequence, throws if clips are invalid.

    In order for a clip sequence to be valid, they must be ordered by time, and time + duration must not exceed the following clip in sequence’s time. It’s recommended to use A clip merger like AKFileClipSequence to build and modify the clips sequence.

    Throws

    ClipMergeError if clips aren’t valid.

    Declaration

    Swift

    open func setClips(clips: [FileClip]) throws

    Parameters

    clips

    a validated array of Objects conforming to the FileClip protocol, use AKFileClips if you don’t need custom behavior.

  • A valid clip sequence.

    Declaration

    Swift

    open var clips: [FileClip]
  • Initializes a clipPlayer with clips.

    See setClips for discussion of clips validation

    Declaration

    Swift

    public convenience init?(clips: [AKFileClip])

    Parameters

    clips

    a validated array of Objects conforming to the FileClip protocol, use AKFileClips if you don’t need custom behavior.

    Return Value

    A new player with clips if clips are valid, nil if not.

  • Declaration

    Swift

    public override init()
  • Prepares previously scheduled file regions or buffers for playback.

    Declaration

    Swift

    open func prepare(withFrameCount frameCount: AVAudioFrameCount)

    Parameters

    frameCount

    The number of sample frames of data to be prepared before returning.

  • Starts playback at next render cycle, AVAudioEngine must be running.

    Declaration

    Swift

    open func play()
  • Starts playback at time

    Declaration

    Swift

    open func play(at audioTime: AVAudioTime?)

    Parameters

    audioTime

    A time in the audio render context. If non-nil, the player’s current current time will align with this time when playback starts.

  • Stops playback.

    Declaration

    Swift

    open func stop()
  • Volume 0.0 -> 1.0, default 1.0

    Declaration

    Swift

    open var volume: Float
  • pan

    Left/Right balance -1.0 -> 1.0, default 0.0

    Declaration

    Swift

    open var pan: Float