| title | date | version |
|---|---|---|
ExSubtitle |
0.0.1 |
ExSubtitle provides interface for external subtitle that is not supported by AVPlayer.
- parses an external subtitle with source
- notifies a timed text and additional information based on the playback position of
AVPlayer
- TTML (application/xml+ttml, application/ttml+xml)
- WebVTT (text/vtt)
- SRT (application/x-subrip)
- SMI (application/smil+xml)
- ASS (application/x-ass)
Constants that describe types of subtitle.
enum MimeType {
case smi, srt, ass, vtt, ttml
}| Name | Description |
|---|---|
| ttml | TimedTextMarkupLanguage |
| vtt | WebVTT |
| srt | SubRip |
| smi | SAMI |
| ass | SubStationAlpha |
Applicaton should create the ExSubtitle instance with an AVPlayer.
Declaration:
init(player: AVPlayer)Parameters:
| Name | Description |
|---|---|
| player | AVPlayer |
Example:
var asset = AVAsset(url: url)
var playerItem = AVPlayerItem(asset: asset)
var player = AVPlayer(playerItem: playerItem)
var exSubtitle = ExSubtitle(player: player)Applicaton should get the subtitle data and mimtype from the file or url resource.
Declaration:
func parse(from data: Data, mimetype: MimeType)Parameters:
| Name | Description |
|---|---|
| onCue | No description. |
// TODO: error handling
Example:
self.exSubtitle.parse(from: data, mimetype: .ttml)ExSubtitle notities the timed text and information as Cue class via onCue listener.
Declaration:
func setOnCue(_ onCue: @escaping ((Cue) -> Void))Parameters:
| Name | Description |
|---|---|
| onCue | No description. |
Example:
self.exSubtitle.setOnCue {
$0.payloads.forEach {
print("\($0.text)")
}
}Declaration
var start: CMTimeDeclaration
var end: CMTimeDeclaration
typealias Styles = (region: Style?, style: Style?)
typealias Payload = (text: String, setting: String?, styles: Styles?)
var payloads: [Payload]