CueEvent

@objc(BMPCueEvent)
public protocol CueEvent
  • The start time of the cue in seconds

    Declaration

    Swift

    var startTime: TimeInterval { get }
  • The end time of the cue in seconds

    Declaration

    Swift

    var endTime: TimeInterval { get }
  • The cue text

    Declaration

    Swift

    var text: String? { get }
  • The original raw text of the cue, as written in the caption file

    Declaration

    Swift

    var rawText: String? { get }
  • The formatted text content of the cue.

    This property provides the cue’s text content with attributes in the UIKitAttributes format, making it directly usable with UIKit and SwiftUI components that support attributed strings.

    The supported styles include:

    • Foreground color (text color)
    • Background color (of the character)
    • Underline style
    • Italic text style
    • Bold text style

    Limitation:

    1. Side-loaded subtitles: for side-loaded subtitles, only color attributes (foreground and background) are supported. Font-related attributes and underline styles are not available for these types of subtitles.
    2. One font-related attribute at a time: having multiple font-related attributes (italic and bold styles) on the same range is not supported. In this case, only one attribute will be applied.

    Usage Example:

    import SwiftUI
    
    // Use in a SwiftUI `Text` view
    
    guard let attributedText = cueEvent.attributedText else { return }
    Text(AttributedString(attributedText))
    

    Compatibility:

    • UIKit: Directly use the NSAttributedString with UILabel, UITextView, or other UIKit components.
    • SwiftUI: Convert the NSAttributedString to AttributedString using SwiftUI’s built-in support with AttributedString(attributedText), as shown in the usage example above.

    Troubleshooting:

    • SwiftUI: If the formatting is not working, try scoping the attributes to keep during the conversion: swift try AttributedString(attributedText, including: \.uiKit)

    Declaration

    Swift

    var attributedText: NSAttributedString? { get }
  • The cue text as HTML

    Declaration

    Swift

    var html: String? { get }
  • The cue image

    Declaration

    Swift

    var image: UIImage? { get }
  • The position of the cue. Only relevant for CEA-captions, provides information about where the cue should be positioned on a grid of 15 character rows times 32 columns

    Declaration

    Swift

    var position: CuePosition? { get }
  • The region of the cue

    Declaration

    Swift

    var region: String? { get }
  • The region style of the cue

    Declaration

    Swift

    var regionStyle: String? { get }
  • vtt

    The VTT positioning properties for this cue

    Declaration

    Swift

    var vtt: VttProperties? { get }