Class AudioStream.Builder
- java.lang.Object
-
- org.schabi.newpipe.extractor.stream.AudioStream.Builder
-
- Enclosing class:
- AudioStream
public static final class AudioStream.Builder extends java.lang.ObjectClass to buildAudioStreamobjects.
-
-
Constructor Summary
Constructors Constructor Description Builder()Create a newAudioStream.Builderinstance with its default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AudioStreambuild()Build anAudioStreamusing the builder's current values.AudioStream.BuildersetAudioLocale(java.util.Locale audioLocale)Set theLocaleof the audio which represents its language.AudioStream.BuildersetAudioTrackId(java.lang.String audioTrackId)Set the audio track id of theAudioStream.AudioStream.BuildersetAudioTrackName(java.lang.String audioTrackName)Set the audio track name of theAudioStream.AudioStream.BuildersetAudioTrackType(AudioTrackType audioTrackType)Set theAudioTrackTypeof theAudioStream.AudioStream.BuildersetAverageBitrate(int averageBitrate)Set the average bitrate of theAudioStream.AudioStream.BuildersetContent(java.lang.String content, boolean isUrl)Set the content of theAudioStream.AudioStream.BuildersetDeliveryMethod(DeliveryMethod deliveryMethod)Set theDeliveryMethodof theAudioStream.AudioStream.BuildersetId(java.lang.String id)Set the identifier of theAudioStream.AudioStream.BuildersetItagItem(ItagItem itagItem)Set theItagItemcorresponding to theAudioStream.AudioStream.BuildersetManifestUrl(java.lang.String manifestUrl)Sets the URL of the manifest this stream comes from (if applicable, otherwise null).AudioStream.BuildersetMediaFormat(MediaFormat mediaFormat)Set theMediaFormatused by theAudioStream.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a newAudioStream.Builderinstance with its default values.
-
-
Method Detail
-
setId
public AudioStream.Builder setId(@Nonnull java.lang.String id)
Set the identifier of theAudioStream.It must not be null and should be non empty.
If you are not able to get an identifier, use the static constant
ID_UNKNOWNof theStreamclass.- Parameters:
id- the identifier of theAudioStream, which must not be null- Returns:
- this
AudioStream.Builderinstance
-
setContent
public AudioStream.Builder setContent(@Nonnull java.lang.String content, boolean isUrl)
Set the content of theAudioStream.It must not be null, and should be non empty.
- Parameters:
content- the content of theAudioStreamisUrl- whether the content is a URL- Returns:
- this
AudioStream.Builderinstance
-
setMediaFormat
public AudioStream.Builder setMediaFormat(@Nullable MediaFormat mediaFormat)
Set theMediaFormatused by theAudioStream.It should be one of the audio
MediaFormats (M4A,WEBMA,MP3,OPUS,OGG, orWEBMA_OPUS) but can benullif the media format could not be determined.The default value is
null.- Parameters:
mediaFormat- theMediaFormatof theAudioStream, which can be null- Returns:
- this
AudioStream.Builderinstance
-
setDeliveryMethod
public AudioStream.Builder setDeliveryMethod(@Nonnull DeliveryMethod deliveryMethod)
Set theDeliveryMethodof theAudioStream.It must not be null.
The default delivery method is
DeliveryMethod.PROGRESSIVE_HTTP.- Parameters:
deliveryMethod- theDeliveryMethodof theAudioStream, which must not be null- Returns:
- this
AudioStream.Builderinstance
-
setManifestUrl
public AudioStream.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
AudioStream.Builderinstance
-
setAverageBitrate
public AudioStream.Builder setAverageBitrate(int averageBitrate)
Set the average bitrate of theAudioStream.The default value is
AudioStream.UNKNOWN_BITRATE.- Parameters:
averageBitrate- the average bitrate of theAudioStream, which should positive- Returns:
- this
AudioStream.Builderinstance
-
setAudioTrackId
public AudioStream.Builder setAudioTrackId(@Nullable java.lang.String audioTrackId)
Set the audio track id of theAudioStream.The default value is
null.- Parameters:
audioTrackId- the audio track id of theAudioStream, which can be null- Returns:
- this
AudioStream.Builderinstance
-
setAudioTrackName
public AudioStream.Builder setAudioTrackName(@Nullable java.lang.String audioTrackName)
Set the audio track name of theAudioStream.The default value is
null.- Parameters:
audioTrackName- the audio track name of theAudioStream, which can be null- Returns:
- this
AudioStream.Builderinstance
-
setAudioTrackType
public AudioStream.Builder setAudioTrackType(AudioTrackType audioTrackType)
- Parameters:
audioTrackType- the audio track type of theAudioStream, which can be null- Returns:
- this
AudioStream.Builderinstance
-
setAudioLocale
public AudioStream.Builder setAudioLocale(@Nullable java.util.Locale audioLocale)
Set theLocaleof the audio which represents its language.The default value is
null, which means that theLocaleis unknown.- Parameters:
audioLocale- theLocaleof the audio, which could benull- Returns:
- this
AudioStream.Builderinstance
-
setItagItem
public AudioStream.Builder setItagItem(@Nullable ItagItem itagItem)
Set theItagItemcorresponding to theAudioStream.ItagItems are YouTube specific objects, so they are only known for this service and can be null.The default value is
null.- Parameters:
itagItem- theItagItemof theAudioStream, which can be null- Returns:
- this
AudioStream.Builderinstance
-
build
@Nonnull public AudioStream build()
Build anAudioStreamusing the builder's current values.The identifier and the content (and so the
isUrlboolean) properties must have been set.- Returns:
- a new
AudioStreamusing the builder's current values - Throws:
java.lang.IllegalStateException- ifid,content(and soisUrl) ordeliveryMethodhave been not set, or have been set asnull
-
-