Player

public class Player : NSObject

Player uses input to take processed frames, draw effect and present them into the outputs.

  • Declaration

    Swift

    public let effectPlayer: BNBEffectPlayer
  • Rendering modes

    See more

    Declaration

    Swift

    public enum RenderMode
  • Setup rendering mode, loop by default

    Declaration

    Swift

    public var renderMode: RenderMode { get set }
  • Current player size

    Declaration

    Swift

    public var size: CGSize { get }
  • Player volume in range [0, 1] where 1 is maximum

    Declaration

    Swift

    public var volume: Float { get set }
  • Current effect

    Declaration

    Swift

    public var effect: BNBEffect? { get }
  • Create player play should be called after create, to start effect applying

    Declaration

    Swift

    public init(fps: Int = 30)

    Parameters

    fps

    max rendering frame rate, 30 by default

  • Start playback

    Declaration

    Swift

    public func play()
  • Pause playback

    Declaration

    Swift

    public func pause()
  • Use provided input with current outputs

    Declaration

    Swift

    public func use(input: Input?)
  • Use provided outputs with current input

    Declaration

    Swift

    public func use(outputs: [Output])
  • Use provided input and outputs

    Declaration

    Swift

    public func use(input: Input?, outputs: [Output])
  • Load effect with path

    Declaration

    Swift

    public func load(effect: String, sync: Bool = false, completion: ((BNBEffect?) -> Void)? = nil) -> BNBEffect?

    Parameters

    effect

    path to effect

    sync

    wait until effect is loaded

    completion

    callback is fired when effect becomes active, argument can be nil if loading error or another effect was loaded

  • Setup callback on resize event

    Declaration

    Swift

    public func onResize(action: @escaping (CGSize) -> Void)

    Parameters

    action

    callback is fired when input gives frame with changed size

  • Setup callback on render event

    Declaration

    Swift

    public func onRender(action: @escaping (Bool, Int64) -> Void)

    Parameters

    action

    callback which reports status and frameNumber, if success

  • Draw and present rendered result synchronously, can be used only in manual rendering mode.

    Declaration

    Swift

    public func render() -> Bool