Skip to main content

Teleprompter Content and Settings

Inspect the current slot, send overlay-prompt text, switch slots, clear content, and update the shared scroll speed.

Prerequisites

  • The device is connected and conforms to TeleprompterAPI.
  • The selected slot index is in 0...(overlayPromptTotalSlots - 1).
  • The prompt's encoded byte size fits within capacityBytesOfCurrentOverlayPromptSlot.

API Reference

Framework

AIBuds.xcframework

Import

Swift
import AIBuds

Protocol

Swift
/// Teleprompter API
protocol TeleprompterAPI: DeviceAPI {
    /// The overlay prompt scroll speed; all slots share this value.
    /// 100 is 1.0×, 150 is 1.5×, minimum 10 (0.1×), maximum 1000 (10×).
    var overlayPromptScrollSpeed: NSNumber? { get }

    /// The total number of overlay prompt slots.
    var overlayPromptTotalSlots: NSNumber? { get }

    /// The current zero-based overlay prompt slot index.
    var overlayPromptSlotIndex: NSNumber? { get }

    /// The current overlay prompt slot used bytes.
    var usedBytesOfCurrentOverlayPromptSlot: NSNumber? { get }

    /// The current overlay prompt slot capacity in bytes.
    var capacityBytesOfCurrentOverlayPromptSlot: NSNumber? { get }

    /// Sends an overlay prompt to the device.
    /// - Parameters:
    ///   - prompt: The overlay prompt to send.
    ///   - progressHandler: Called when transfer progress changes.
    ///   - completionHandler: Called when the operation completes with success and an optional error.
    func sendOverlayPrompt(
        _ prompt: String,
        progressHandler: (
            (
                _ progress: CGFloat
            ) -> Void
        )?,
        completionHandler: AIBudsCompletionHandler?
    )

    /// Clears the current overlay prompt slot content.
    /// - Parameter completion: Called when the operation completes with success and an optional error.
    func clearCurrentOverlayPromptSlotContent(_ completion: AIBudsCompletionHandler?)

    /// Switches to the specified zero-based slot index.
    /// - Parameters:
    ///   - index: A value from 0 through `overlayPromptTotalSlots - 1`.
    ///   - completion: Called when the operation completes with success and an optional error.
    func toggleOverlayPromptSlotIndexTo(
        _ index: Int,
        completion: AIBudsCompletionHandler?
    )

    /// Sets the shared overlay prompt scroll speed.
    /// - Parameters:
    ///   - speed: 10...1000, where 100 represents 1.0×.
    ///   - completion: Called when the operation completes with success and an optional error.
    func setOverlayPromptScrollSpeed(
        _ speed: Int,
        completion: AIBudsCompletionHandler?
    )
}

Symbols

SymbolPurpose
sendOverlayPromptSend text with progress.
clearCurrentOverlayPromptSlotContentClear the current slot.
toggleOverlayPromptSlotIndexToSwitch slots.
setOverlayPromptScrollSpeedSet the shared scroll speed.

Usage Examples

Swift
guard let device = device as? TeleprompterAPI else { return }

guard let capacity = device.capacityBytesOfCurrentOverlayPromptSlot?.intValue else {
    print("Slot capacity unavailable")
    return
}

let prompt = "Welcome to AIBuds"
guard prompt.lengthOfBytes(using: .utf8) <= capacity else {
    print("Prompt exceeds the current slot capacity")
    return
}

device.sendOverlayPrompt(
    prompt,
    progressHandler: { progress in
        print("Transfer: \(Int(progress * 100))%")
    }
) { success, error in
    if !success { print(error?.localizedDescription ?? "Transfer failed") }
}

device.setOverlayPromptScrollSpeed(150, completion: nil)  // 1.5×

Error Handling

Validate slot index, UTF-8 byte length, and speed before sending commands. If a transfer fails, keep the current slot selected and allow the user to retry; do not assume partial prompt content is usable.