Class SubtitlesStream.Builder
- java.lang.Object
-
- org.schabi.newpipe.extractor.stream.SubtitlesStream.Builder
-
- Enclosing class:
- SubtitlesStream
public static final class SubtitlesStream.Builder extends java.lang.Object
Class to buildSubtitlesStream
objects.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Create a newSubtitlesStream.Builder
instance with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SubtitlesStream
build()
Build aSubtitlesStream
using the builder's current values.SubtitlesStream.Builder
setAutoGenerated(boolean autoGenerated)
Set whether the subtitles have been auto-generated by the streaming service.SubtitlesStream.Builder
setContent(java.lang.String content, boolean isUrl)
Set the content of theSubtitlesStream
.SubtitlesStream.Builder
setDeliveryMethod(DeliveryMethod deliveryMethod)
Set theDeliveryMethod
of theSubtitlesStream
.SubtitlesStream.Builder
setId(java.lang.String id)
Set the identifier of theSubtitlesStream
.SubtitlesStream.Builder
setLanguageCode(java.lang.String languageCode)
Set the language code of theSubtitlesStream
.SubtitlesStream.Builder
setManifestUrl(java.lang.String manifestUrl)
Sets the URL of the manifest this stream comes from (if applicable, otherwise null).SubtitlesStream.Builder
setMediaFormat(MediaFormat mediaFormat)
Set theMediaFormat
used by theSubtitlesStream
.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a newSubtitlesStream.Builder
instance with default values.
-
-
Method Detail
-
setId
public SubtitlesStream.Builder setId(@Nonnull java.lang.String id)
Set the identifier of theSubtitlesStream
.- Parameters:
id
- the identifier of theSubtitlesStream
, which should not be null (otherwise the fallback to create the identifier will be used when building the builder)- Returns:
- this
SubtitlesStream.Builder
instance
-
setContent
public SubtitlesStream.Builder setContent(@Nonnull java.lang.String content, boolean isUrl)
Set the content of theSubtitlesStream
.It must not be null, and should be non empty.
- Parameters:
content
- the content of theSubtitlesStream
, which must not be nullisUrl
- whether the content is a URL- Returns:
- this
SubtitlesStream.Builder
instance
-
setMediaFormat
public SubtitlesStream.Builder setMediaFormat(@Nullable MediaFormat mediaFormat)
Set theMediaFormat
used by theSubtitlesStream
.It should be one of the subtitles
MediaFormat
s (SRT
,TRANSCRIPT1
,TRANSCRIPT2
,TRANSCRIPT3
,TTML
, orVTT
) but can benull
if the media format could not be determined.The default value is
null
.- Parameters:
mediaFormat
- theMediaFormat
of theSubtitlesStream
, which can be null- Returns:
- this
SubtitlesStream.Builder
instance
-
setDeliveryMethod
public SubtitlesStream.Builder setDeliveryMethod(@Nonnull DeliveryMethod deliveryMethod)
Set theDeliveryMethod
of theSubtitlesStream
.It must not be null.
The default delivery method is
DeliveryMethod.PROGRESSIVE_HTTP
.- Parameters:
deliveryMethod
- theDeliveryMethod
of theSubtitlesStream
, which must not be null- Returns:
- this
SubtitlesStream.Builder
instance
-
setManifestUrl
public SubtitlesStream.Builder setManifestUrl(@Nullable java.lang.String manifestUrl)
Sets the URL of the manifest this stream comes from (if applicable, otherwise null).- Parameters:
manifestUrl
- the URL of the manifest this stream comes from ornull
- Returns:
- this
SubtitlesStream.Builder
instance
-
setLanguageCode
public SubtitlesStream.Builder setLanguageCode(@Nonnull java.lang.String languageCode)
Set the language code of theSubtitlesStream
.It must not be null and should not be an empty string.
- Parameters:
languageCode
- the language code of theSubtitlesStream
- Returns:
- this
SubtitlesStream.Builder
instance
-
setAutoGenerated
public SubtitlesStream.Builder setAutoGenerated(boolean autoGenerated)
Set whether the subtitles have been auto-generated by the streaming service.- Parameters:
autoGenerated
- whether the subtitles have been generated by the streaming service- Returns:
- this
SubtitlesStream.Builder
instance
-
build
@Nonnull public SubtitlesStream build() throws ParsingException
Build aSubtitlesStream
using the builder's current values.The content (and so the
isUrl
boolean), the language code and theisAutoGenerated
properties must have been set.If no identifier has been set, an identifier will be generated using the language code and the media format suffix, if the media format is known.
- Returns:
- a new
SubtitlesStream
using the builder's current values - Throws:
java.lang.IllegalStateException
- ifid
,content
(and soisUrl
),deliveryMethod
,languageCode
or theisAutogenerated
have been not set, or have been set asnull
ParsingException
-
-