SubtitleSource

data class SubtitleSource(val uri: String, val title: String? = null, val language: String? = null, val selectImmediately: Boolean = false, val io: MediaIoFactory? = null, val encoding: String? = null)

An external subtitle file added alongside a media item.

SubRip, WebVTT and ASS files load at open: each becomes a selectable synthetic subtitle track (a negative io.github.yuroyami.kiteplayer.TrackId, labelled by title or the file name) whose cues run through the same engine timing path container cues use. A file that cannot be read or parsed warns typed and is skipped rather than failing the open.

Where the bytes come from, in order: io when set; then, for an http or https uri, the network resolver; then uri as a local path.

The network resolver gets the parent item's MediaItem.headers only when uri has the same scheme, host and port as the item's own URI, so a subtitle beside a signed URL works. A subtitle on another server gets no item header. To send headers to it, give it its own io.

The text's encoding is decided from the bytes unless encoding names it: a byte-order mark, then UTF-8, then SubtitleConfig.fallbackEncoding when one is set, and otherwise a guess, which PlaybackWarning.SubtitleCharsetGuessed reports. A track whose guess was wrong can be read again in another encoding with KitePlayer.reloadExternalSubtitle.

Throws

when encoding is not one of ENCODINGS or a label for one.

Constructors

Link copied to clipboard
constructor(uri: String, title: String? = null, language: String? = null, selectImmediately: Boolean = false, io: MediaIoFactory? = null, encoding: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The encoding the file is in, which is then used as it is, with no guess (#515). Null decides from the bytes.

Link copied to clipboard

Read the subtitle bytes through your own code.

Link copied to clipboard
Link copied to clipboard

Selected as soon as it is loaded.

Link copied to clipboard

Shown in a track menu. Defaults to the file name.

Link copied to clipboard
val uri: String