मुख्य कंटेंट तक स्किप करें

टेलीप्रॉम्प्टर सामग्री और सेटिंग्स

मौजूदा slot देखें, overlay-prompt text भेजें, slot बदलें, सामग्री साफ़ करें और साझा scroll speed अपडेट करें।

आवश्यकताएँ

  • डिवाइस कनेक्टेड है और TeleprompterAPI के अनुरूप है।
  • चुना गया slot index 0...(overlayPromptTotalSlots - 1) में है।
  • prompt का encoded byte size capacityBytesOfCurrentOverlayPromptSlot में समाता है।

API संदर्भ

Framework

AIBuds.xcframework

Import

Swift
import AIBuds

प्रोटोकॉल

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 संदर्भ

Symbolउद्देश्य
sendOverlayPromptProgress सहित text भेजता है।
clearCurrentOverlayPromptSlotContentमौजूदा slot साफ़ करता है।
toggleOverlayPromptSlotIndexToSlot बदलता है।
setOverlayPromptScrollSpeedसाझा scroll speed सेट करता है।

उपयोग के उदाहरण

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×

त्रुटि प्रबंधन

Commands भेजने से पहले slot index, UTF-8 byte length और speed validate करें। Transfer विफल हो तो मौजूदा slot चुना रहने दें और उपयोगकर्ता को फिर प्रयास करने दें; आंशिक prompt content को usable न मानें।