Class VideoStream.Builder
- java.lang.Object
-
- org.schabi.newpipe.extractor.stream.VideoStream.Builder
-
- Enclosing class:
- VideoStream
public static final class VideoStream.Builder extends java.lang.Object
Class to buildVideoStream
objects.
-
-
Constructor Summary
Constructors Constructor Description Builder()
Create a newVideoStream.Builder
instance with its default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VideoStream
build()
Build aVideoStream
using the builder's current values.VideoStream.Builder
setContent(java.lang.String content, boolean isUrl)
Set the content of theVideoStream
.VideoStream.Builder
setDeliveryMethod(DeliveryMethod deliveryMethod)
Set theDeliveryMethod
of theVideoStream
.VideoStream.Builder
setId(java.lang.String id)
Set the identifier of theVideoStream
.VideoStream.Builder
setIsVideoOnly(boolean isVideoOnly)
Set whether theVideoStream
is video-only.VideoStream.Builder
setItagItem(ItagItem itagItem)
Set theItagItem
corresponding to theVideoStream
.VideoStream.Builder
setManifestUrl(java.lang.String manifestUrl)
Sets the URL of the manifest this stream comes from (if applicable, otherwise null).VideoStream.Builder
setMediaFormat(MediaFormat mediaFormat)
Set theMediaFormat
used by theVideoStream
.VideoStream.Builder
setResolution(java.lang.String resolution)
Set the resolution of theVideoStream
.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a newVideoStream.Builder
instance with its default values.
-
-
Method Detail
-
setId
public VideoStream.Builder setId(@Nonnull java.lang.String id)
Set the identifier of theVideoStream
.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 theVideoStream
, which must not be null- Returns:
- this
VideoStream.Builder
instance
-
setContent
public VideoStream.Builder setContent(@Nonnull java.lang.String content, boolean isUrl)
Set the content of theVideoStream
.It must not be null, and should be non empty.
- Parameters:
content
- the content of theVideoStream
isUrl
- whether the content is a URL- Returns:
- this
VideoStream.Builder
instance
-
setMediaFormat
public VideoStream.Builder setMediaFormat(@Nullable MediaFormat mediaFormat)
Set theMediaFormat
used by theVideoStream
.It should be one of the video
MediaFormat
s (MPEG_4
,v3GPP
, orWEBM
) but can benull
if the media format could not be determined.The default value is
null
.- Parameters:
mediaFormat
- theMediaFormat
of theVideoStream
, which can be null- Returns:
- this
VideoStream.Builder
instance
-
setDeliveryMethod
public VideoStream.Builder setDeliveryMethod(@Nonnull DeliveryMethod deliveryMethod)
Set theDeliveryMethod
of theVideoStream
.It must not be null.
The default delivery method is
DeliveryMethod.PROGRESSIVE_HTTP
.- Parameters:
deliveryMethod
- theDeliveryMethod
of theVideoStream
, which must not be null- Returns:
- this
VideoStream.Builder
instance
-
setManifestUrl
public VideoStream.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
VideoStream.Builder
instance
-
setIsVideoOnly
public VideoStream.Builder setIsVideoOnly(boolean isVideoOnly)
Set whether theVideoStream
is video-only.This property must be set before building the
VideoStream
.- Parameters:
isVideoOnly
- whether theVideoStream
is video-only- Returns:
- this
VideoStream.Builder
instance
-
setResolution
public VideoStream.Builder setResolution(@Nonnull java.lang.String resolution)
Set the resolution of theVideoStream
.This resolution can be used by clients to know the quality of the video stream.
If you are not able to know the resolution, you should use
VideoStream.RESOLUTION_UNKNOWN
as the resolution of the video stream.It must be set before building the builder and not null.
- Parameters:
resolution
- the resolution of theVideoStream
- Returns:
- this
VideoStream.Builder
instance
-
setItagItem
public VideoStream.Builder setItagItem(@Nullable ItagItem itagItem)
Set theItagItem
corresponding to theVideoStream
.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 theVideoStream
, which can be null- Returns:
- this
VideoStream.Builder
instance
-
build
@Nonnull public VideoStream build()
Build aVideoStream
using the builder's current values.The identifier, the content (and so the
isUrl
boolean), theisVideoOnly
and theresolution
properties must have been set.- Returns:
- a new
VideoStream
using the builder's current values - Throws:
java.lang.IllegalStateException
- ifid
,content
(and soisUrl
),deliveryMethod
,isVideoOnly
orresolution
have been not set, or have been set asnull
-
-