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.Object
Class to buildAudioStream
objects.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Create a newAudioStream.Builder
instance with its default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AudioStream
build()
Build anAudioStream
using the builder's current values.AudioStream.Builder
setAudioLocale(java.util.Locale audioLocale)
Set theLocale
of the audio which represents its language.AudioStream.Builder
setAudioTrackId(java.lang.String audioTrackId)
Set the audio track id of theAudioStream
.AudioStream.Builder
setAudioTrackName(java.lang.String audioTrackName)
Set the audio track name of theAudioStream
.AudioStream.Builder
setAudioTrackType(AudioTrackType audioTrackType)
Set theAudioTrackType
of theAudioStream
.AudioStream.Builder
setAverageBitrate(int averageBitrate)
Set the average bitrate of theAudioStream
.AudioStream.Builder
setContent(java.lang.String content, boolean isUrl)
Set the content of theAudioStream
.AudioStream.Builder
setDeliveryMethod(DeliveryMethod deliveryMethod)
Set theDeliveryMethod
of theAudioStream
.AudioStream.Builder
setId(java.lang.String id)
Set the identifier of theAudioStream
.AudioStream.Builder
setItagItem(ItagItem itagItem)
Set theItagItem
corresponding to theAudioStream
.AudioStream.Builder
setManifestUrl(java.lang.String manifestUrl)
Sets the URL of the manifest this stream comes from (if applicable, otherwise null).AudioStream.Builder
setMediaFormat(MediaFormat mediaFormat)
Set theMediaFormat
used by theAudioStream
.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a newAudioStream.Builder
instance 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_UNKNOWN
of theStream
class.- Parameters:
id
- the identifier of theAudioStream
, which must not be null- Returns:
- this
AudioStream.Builder
instance
-
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 theAudioStream
isUrl
- whether the content is a URL- Returns:
- this
AudioStream.Builder
instance
-
setMediaFormat
public AudioStream.Builder setMediaFormat(@Nullable MediaFormat mediaFormat)
Set theMediaFormat
used by theAudioStream
.It should be one of the audio
MediaFormat
s (M4A
,WEBMA
,MP3
,OPUS
,OGG
, orWEBMA_OPUS
) but can benull
if the media format could not be determined.The default value is
null
.- Parameters:
mediaFormat
- theMediaFormat
of theAudioStream
, which can be null- Returns:
- this
AudioStream.Builder
instance
-
setDeliveryMethod
public AudioStream.Builder setDeliveryMethod(@Nonnull DeliveryMethod deliveryMethod)
Set theDeliveryMethod
of theAudioStream
.It must not be null.
The default delivery method is
DeliveryMethod.PROGRESSIVE_HTTP
.- Parameters:
deliveryMethod
- theDeliveryMethod
of theAudioStream
, which must not be null- Returns:
- this
AudioStream.Builder
instance
-
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.Builder
instance
-
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.Builder
instance
-
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.Builder
instance
-
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.Builder
instance
-
setAudioTrackType
public AudioStream.Builder setAudioTrackType(AudioTrackType audioTrackType)
- Parameters:
audioTrackType
- the audio track type of theAudioStream
, which can be null- Returns:
- this
AudioStream.Builder
instance
-
setAudioLocale
public AudioStream.Builder setAudioLocale(@Nullable java.util.Locale audioLocale)
Set theLocale
of the audio which represents its language.The default value is
null
, which means that theLocale
is unknown.- Parameters:
audioLocale
- theLocale
of the audio, which could benull
- Returns:
- this
AudioStream.Builder
instance
-
setItagItem
public AudioStream.Builder setItagItem(@Nullable ItagItem itagItem)
Set theItagItem
corresponding to theAudioStream
.ItagItem
s are YouTube specific objects, so they are only known for this service and can be null.The default value is
null
.- Parameters:
itagItem
- theItagItem
of theAudioStream
, which can be null- Returns:
- this
AudioStream.Builder
instance
-
build
@Nonnull public AudioStream build()
Build anAudioStream
using the builder's current values.The identifier and the content (and so the
isUrl
boolean) properties must have been set.- Returns:
- a new
AudioStream
using the builder's current values - Throws:
java.lang.IllegalStateException
- ifid
,content
(and soisUrl
) ordeliveryMethod
have been not set, or have been set asnull
-
-