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.ObjectClass to buildSubtitlesStreamobjects.
-
-
Constructor Summary
Constructors Constructor Description Builder()Create a newSubtitlesStream.Builderinstance with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SubtitlesStreambuild()Build aSubtitlesStreamusing the builder's current values.SubtitlesStream.BuildersetAutoGenerated(boolean autoGenerated)Set whether the subtitles have been auto-generated by the streaming service.SubtitlesStream.BuildersetContent(java.lang.String content, boolean isUrl)Set the content of theSubtitlesStream.SubtitlesStream.BuildersetDeliveryMethod(DeliveryMethod deliveryMethod)Set theDeliveryMethodof theSubtitlesStream.SubtitlesStream.BuildersetId(java.lang.String id)Set the identifier of theSubtitlesStream.SubtitlesStream.BuildersetLanguageCode(java.lang.String languageCode)Set the language code of theSubtitlesStream.SubtitlesStream.BuildersetManifestUrl(java.lang.String manifestUrl)Sets the URL of the manifest this stream comes from (if applicable, otherwise null).SubtitlesStream.BuildersetMediaFormat(MediaFormat mediaFormat)Set theMediaFormatused by theSubtitlesStream.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a newSubtitlesStream.Builderinstance 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.Builderinstance
-
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.Builderinstance
-
setMediaFormat
public SubtitlesStream.Builder setMediaFormat(@Nullable MediaFormat mediaFormat)
Set theMediaFormatused by theSubtitlesStream.It should be one of the subtitles
MediaFormats (SRT,TRANSCRIPT1,TRANSCRIPT2,TRANSCRIPT3,TTML, orVTT) but can benullif the media format could not be determined.The default value is
null.- Parameters:
mediaFormat- theMediaFormatof theSubtitlesStream, which can be null- Returns:
- this
SubtitlesStream.Builderinstance
-
setDeliveryMethod
public SubtitlesStream.Builder setDeliveryMethod(@Nonnull DeliveryMethod deliveryMethod)
Set theDeliveryMethodof theSubtitlesStream.It must not be null.
The default delivery method is
DeliveryMethod.PROGRESSIVE_HTTP.- Parameters:
deliveryMethod- theDeliveryMethodof theSubtitlesStream, which must not be null- Returns:
- this
SubtitlesStream.Builderinstance
-
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.Builderinstance
-
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.Builderinstance
-
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.Builderinstance
-
build
@Nonnull public SubtitlesStream build() throws ParsingException
Build aSubtitlesStreamusing the builder's current values.The content (and so the
isUrlboolean), the language code and theisAutoGeneratedproperties 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
SubtitlesStreamusing the builder's current values - Throws:
java.lang.IllegalStateException- ifid,content(and soisUrl),deliveryMethod,languageCodeor theisAutogeneratedhave been not set, or have been set asnullParsingException
-
-