Class PlayerConfig
- java.lang.Object
-
- com.longtailvideo.jwplayer.configuration.PlayerConfig
-
- All Implemented Interfaces:
com.longtailvideo.jwplayer.utils.Jsonable
public final class PlayerConfig extends java.lang.Object implements com.longtailvideo.jwplayer.utils.Jsonable
Player configuration used to set up the player, contains all basic configuration attributes from XML custom attrs or the builder, along with Playlist and Advertising settings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PlayerConfig.Builder
static interface
PlayerConfig.Stretching
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_ALLOW_CROSS_PROTOCOL_REDIRECTS
Configuration valuesstatic java.lang.String
STRETCHING_EXACT_FIT
Will fit JW Player dimensions without maintaining aspect ratio.static java.lang.String
STRETCHING_FILL
Will zoom and crop video to fill dimensions, maintaining aspect ratio.static java.lang.String
STRETCHING_NONE
Displays the actual size of the video file with black borders.static java.lang.String
STRETCHING_UNIFORM
Will fit JW Player dimensions while maintaining aspect ratio.
-
Constructor Summary
Constructors Constructor Description PlayerConfig(PlayerConfig src)
Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AdvertisingBase
getAdvertising()
boolean
getAllowCrossProtocolRedirects()
boolean
getAutostart()
CaptionsConfig
getCaptionsConfig()
boolean
getControls()
boolean
getDisplayDescription()
boolean
getDisplayTitle()
java.lang.String
getFile()
java.lang.String
getImage()
LogoConfig
getLogoConfig()
boolean
getMute()
java.lang.Boolean
getNextUpDisplay()
int
getNextUpOffset()
int
getNextUpOffsetPercentage()
PlaybackRateConfig
getPlaybackRatesConfig()
java.util.List<PlaylistItem>
getPlaylist()
java.lang.Integer
getPlaylistIndex()
boolean
getPreload()
RelatedConfig
getRelatedConfig()
boolean
getRepeat()
SharingConfig
getSharingConfig()
SkinConfig
getSkinConfig()
java.lang.String
getStretching()
static PlayerConfig
parseJson(java.lang.String json)
Parses a PlayerConfig from the given JSON string.void
setAdvertising(AdvertisingBase advertising)
void
setAllowCrossProtocolRedirects(java.lang.Boolean allowCrossProtocolRedirects)
void
setAutostart(java.lang.Boolean autoStart)
void
setCaptionsConfig(CaptionsConfig captionsConfig)
void
setControls(java.lang.Boolean controls)
void
setDisplayDescription(java.lang.Boolean displayDescription)
void
setDisplayTitle(java.lang.Boolean displayTitle)
void
setFile(java.lang.String file)
void
setImage(java.lang.String image)
void
setLogoConfig(LogoConfig logoConfig)
void
setMute(java.lang.Boolean mute)
void
setNextUpDisplay(java.lang.Boolean nextUpDisplay)
void
setNextUpOffset(java.lang.Integer nextUpOffset)
void
setNextUpOffsetPercentage(java.lang.Integer nextUpOffsetPercentage)
void
setPlaybackRatesConfig(PlaybackRateConfig playbackRateConfig)
void
setPlaylist(java.util.List<PlaylistItem> playlist)
void
setPlaylistIndex(java.lang.Integer playlistIndex)
void
setPreload(java.lang.Boolean preload)
void
setRelatedConfig(RelatedConfig relatedConfig)
void
setRepeat(java.lang.Boolean repeat)
void
setSharingConfig(SharingConfig sharingConfig)
void
setSkinConfig(SkinConfig skinConfig)
void
setStretching(java.lang.String stretching)
void
setUseTextureView(boolean useTextureView)
SetsTextureView
to be the view where video content will be rendered Notice that by defaultSurfaceView
is using In case of usingTextureView
DRM streams will not be shown TextureView should be used only if SurfaceView does not meet your needs.org.json.JSONObject
toJson()
java.lang.String
toPlayerSetupBlock(com.longtailvideo.jwplayer.analytics.Analytics analytics, LocalizationConfig config)
java.lang.String
toString()
boolean
usesAdvertising()
boolean
usesCaptions()
Returns true if the player config uses any caption features.boolean
usesDrm()
boolean
useTextureView()
-
-
-
Field Detail
-
STRETCHING_UNIFORM
public static final java.lang.String STRETCHING_UNIFORM
Will fit JW Player dimensions while maintaining aspect ratio.- See Also:
- Constant Field Values
-
STRETCHING_FILL
public static final java.lang.String STRETCHING_FILL
Will zoom and crop video to fill dimensions, maintaining aspect ratio.- See Also:
- Constant Field Values
-
STRETCHING_EXACT_FIT
public static final java.lang.String STRETCHING_EXACT_FIT
Will fit JW Player dimensions without maintaining aspect ratio.- See Also:
- Constant Field Values
-
STRETCHING_NONE
public static final java.lang.String STRETCHING_NONE
Displays the actual size of the video file with black borders.- See Also:
- Constant Field Values
-
DEFAULT_ALLOW_CROSS_PROTOCOL_REDIRECTS
public static final boolean DEFAULT_ALLOW_CROSS_PROTOCOL_REDIRECTS
Configuration values- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PlayerConfig
public PlayerConfig(PlayerConfig src)
Copy constructor.- Parameters:
src
- the PlayerConfig to copy.
-
-
Method Detail
-
setFile
public void setFile(java.lang.String file)
- Parameters:
file
- URL to a single video file, audio file, or live stream to play.
-
setImage
public void setImage(java.lang.String image)
- Parameters:
image
- URL to a poster image to display before playback starts.
-
setMute
public void setMute(java.lang.Boolean mute)
- Parameters:
mute
- Configures if the player should be muted during playback.
-
setAutostart
public void setAutostart(java.lang.Boolean autoStart)
- Parameters:
autoStart
- Whether the player will attempt to begin playback automatically when a page is loaded.
-
setNextUpOffset
public void setNextUpOffset(java.lang.Integer nextUpOffset)
- Parameters:
nextUpOffset
- Configures when the Next Up card displays when transitioning between playlist items. A positive value is an offset from the start of the video. A negative number is an offset from the end of the video.
-
setNextUpOffsetPercentage
public void setNextUpOffsetPercentage(java.lang.Integer nextUpOffsetPercentage)
- Parameters:
nextUpOffsetPercentage
- Configures when the Next Up card displays during playback based on the percentage of the duration. A positive value is a percentage offset from the start of the video. A negative number is a percentage offset from the end of the video i.e. setting the value to 50 will result in the Next Up card showing when half of the video is played. Setting the value to -25 will result in the Next Up card showing when playback reaches 75% of the video duration. Takes precedence over nextupOffset if both properties are set.
-
setRepeat
public void setRepeat(java.lang.Boolean repeat)
- Parameters:
repeat
- Configures if the player should loop content after a playlist completes.
-
setControls
public void setControls(java.lang.Boolean controls)
- Parameters:
controls
- Whether to display the video controls (control bar and display icons).
-
setDisplayTitle
public void setDisplayTitle(java.lang.Boolean displayTitle)
- Parameters:
displayTitle
- Configures if the title of a media file should be displayed.
-
setDisplayDescription
public void setDisplayDescription(java.lang.Boolean displayDescription)
- Parameters:
displayDescription
- Configures if the description title of a media file should be displayed.
-
setStretching
public void setStretching(java.lang.String stretching)
- Parameters:
stretching
- Resize images and video to fit player dimensions. Must be one of the STRETCHING_ constants.
-
setNextUpDisplay
public void setNextUpDisplay(java.lang.Boolean nextUpDisplay)
- Parameters:
nextUpDisplay
- Configures whether the Next Up modal is displayed.
-
setPreload
public void setPreload(java.lang.Boolean preload)
- Parameters:
preload
- Tells the player if content should be loaded prior to playback. Useful for faster playback speed.
-
setPlaylist
public void setPlaylist(java.util.List<PlaylistItem> playlist)
- Parameters:
playlist
- The playlist of media to play in your player.
-
setPlaylistIndex
public void setPlaylistIndex(java.lang.Integer playlistIndex)
- Parameters:
playlistIndex
- The playlist Index of media to start playing in your player. Its 0 indexed. A positive value is an index from the start of the playlist. A negative number is an index from the end of the playlist. i.e. setting value -1 would end up playing the last video on the playlist.
-
setCaptionsConfig
public void setCaptionsConfig(CaptionsConfig captionsConfig)
- Parameters:
captionsConfig
- The captions configuration to apply to your player.
-
setLogoConfig
public void setLogoConfig(LogoConfig logoConfig)
- Parameters:
logoConfig
- The logo configuration to apply to your player.
-
setSkinConfig
public void setSkinConfig(SkinConfig skinConfig)
- Parameters:
skinConfig
- The skin configuration to apply to your player.
-
setRelatedConfig
public void setRelatedConfig(RelatedConfig relatedConfig)
- Parameters:
relatedConfig
- The related plugin configuration to apply to your player.
-
setSharingConfig
public void setSharingConfig(SharingConfig sharingConfig)
- Parameters:
sharingConfig
- The sharing plugin configuration to apply to your player.
-
setAdvertising
public void setAdvertising(AdvertisingBase advertising)
- Parameters:
advertising
- The advertising configuration and schedule to apply to your player.
-
setAllowCrossProtocolRedirects
public void setAllowCrossProtocolRedirects(java.lang.Boolean allowCrossProtocolRedirects)
-
setPlaybackRatesConfig
public void setPlaybackRatesConfig(PlaybackRateConfig playbackRateConfig)
- Parameters:
playbackRateConfig
- playback rate config to apply to your player.- See Also:
PlaybackRateConfig
-
setUseTextureView
public void setUseTextureView(boolean useTextureView)
SetsTextureView
to be the view where video content will be rendered Notice that by defaultSurfaceView
is using In case of usingTextureView
DRM streams will not be shown TextureView should be used only if SurfaceView does not meet your needs. One example is where smooth animations or scrolling of the video surface is required prior to Android N. For this case, it’s preferable to use TextureView only when SDK_INT is less than 24 (Android N) and SurfaceView otherwise.- Parameters:
useTextureView
- whether use TextureView as the View where video content is playing true to useTextureView
false to useSurfaceView
-
useTextureView
public boolean useTextureView()
- Returns:
- whether default view where video content should be rendered
is set to
TextureView
-
getFile
@Nullable public java.lang.String getFile()
- Returns:
- URL to a single video file, audio file, or live stream to play.
-
getImage
@Nullable public java.lang.String getImage()
- Returns:
- URL to a poster image to display before playback starts.
-
getMute
public boolean getMute()
- Returns:
- Configures if the player should be muted during playback.
-
getAutostart
public boolean getAutostart()
- Returns:
- Whether the player will attempt to begin playback automatically when a page is loaded.
-
getNextUpOffset
public int getNextUpOffset()
- Returns:
- Configures when the Next Up card displays when transitioning between playlist items. A positive value is an offset from the start of the video. A negative number is an offset from the end of the video.
-
getNextUpOffsetPercentage
public int getNextUpOffsetPercentage()
- Returns:
- Configures when the Next Up card displays during playback based on the percentage of the duration. A positive value is a percentage offset from the start of the video. A negative number is a percentage offset from the end of the video 0 means this property was not set i.e. setting the value to 50 will result in the Next Up card showing when half of the video is played. Setting the value to -25 will result in the Next Up card showing when playback reaches 75% of the video duration. Takes precedence over nextupOffset if both properties are set.
-
getRepeat
public boolean getRepeat()
- Returns:
- Configures if the player should loop content after a playlist completes.
-
getControls
public boolean getControls()
- Returns:
- Whether to display the video controls (control bar and display icons).
-
getDisplayTitle
public boolean getDisplayTitle()
- Returns:
- Configures if the title of a media file should be displayed.
-
getDisplayDescription
public boolean getDisplayDescription()
- Returns:
- Configures if the description title of a media file should be displayed.
-
getStretching
@NonNull public java.lang.String getStretching()
- Returns:
- Resize images and video to fit player dimensions. Must be one of the STRETCHING_ constants.
-
getNextUpDisplay
@Nullable public java.lang.Boolean getNextUpDisplay()
- Returns:
- Configures whether the Next Up modal is displayed.
-
getPreload
public boolean getPreload()
- Returns:
- Tells the player if content should be loaded prior to playback. Useful for faster playback speed.
-
getPlaylist
@Nullable public java.util.List<PlaylistItem> getPlaylist()
- Returns:
- The playlist of media to play in your player.
-
getPlaylistIndex
public java.lang.Integer getPlaylistIndex()
- Returns:
- The playlist index configured to start with in your playlist.
-
getCaptionsConfig
@Nullable public CaptionsConfig getCaptionsConfig()
- Returns:
- The captions configuration to apply to your player.
-
getLogoConfig
@Nullable public LogoConfig getLogoConfig()
- Returns:
- The logo configuration to apply to your player.
-
getSkinConfig
@Nullable public SkinConfig getSkinConfig()
- Returns:
- The skin configuration to apply to your player.
-
getRelatedConfig
public RelatedConfig getRelatedConfig()
- Returns:
- The related plugin configuration to apply to your player.
-
getSharingConfig
public SharingConfig getSharingConfig()
- Returns:
- The sharing plugin configuration to apply to your player.
-
getAdvertising
@Nullable public AdvertisingBase getAdvertising()
- Returns:
- The advertising configuration and schedule to apply to your player.
-
getPlaybackRatesConfig
public PlaybackRateConfig getPlaybackRatesConfig()
- Returns:
- Playback rates values
-
getAllowCrossProtocolRedirects
public boolean getAllowCrossProtocolRedirects()
-
usesAdvertising
public boolean usesAdvertising()
- Returns:
- Returns true if this player config uses advertising features.
-
usesCaptions
public boolean usesCaptions()
Returns true if the player config uses any caption features.- Returns:
- true if captions are being used.
-
usesDrm
public boolean usesDrm()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toJson
public org.json.JSONObject toJson()
- Specified by:
toJson
in interfacecom.longtailvideo.jwplayer.utils.Jsonable
-
parseJson
public static PlayerConfig parseJson(java.lang.String json)
Parses a PlayerConfig from the given JSON string.- Parameters:
json
- the json to parse.- Returns:
- the playerconfig or null if the json was invalid.
-
toPlayerSetupBlock
public java.lang.String toPlayerSetupBlock(com.longtailvideo.jwplayer.analytics.Analytics analytics, LocalizationConfig config)
-
-