public protocol SubtitlesAPI
Loads and displays subtitles.
public protocol SubtitlesAPI
Loads and displays subtitles.
Side-load subtitles content from a URL.
Downloads and parses the subtitles content (if a supported format types). Creates a new subtitle track appended after any existing subtitle tracks. This requires the Subtitles Plugin. Subtitle tracks exist only during playback, therefore this function can only create tracks during that time-frame. Text track should define:
sourceUrl
: location where to download the subtitle content file.format
: type of subtitle (webvtt, ttml etc).language
: string defined in RFC5646.label
: Display name of the track.
Remark
The player must be at least in PlaybackState.ready
for this to have effect.
Remark
Sideloaded subtitles will not render in Airplay and Picture in Picture modes.
Swift
func addTextTrack(_ track: TextTrack, completionHandler: Handler?)
track
|
Text track. |
completionHandler
|
Called when track has been downloaded, parsed and is ready to use. |
Deletes all sideloaded subtitle tracks and resets internal state.
Swift
func reset()
Show a preview of the last loaded subtitles track on a UIView, useful for quickly showing the effect of changing style settings.
Call sideloadTrack()
before using this, to load a custom track to display. The last track
loaded will always be the one displayed.
This will only display the first subtitle cue in the track and keep it onscreen permanently.
Swift
func previewSubtitles(withStyle style: SubtitlesStyle, onView view: UIView)
style
|
The style to use when displaying the preview. |
view
|
UIView on which to draw the subtitles preview. It should have an aspect ratio roughly equivalent to a video for accurate results. |