Package com.jwplayer.pub.api
Interface JWPlayer
-
public interface JWPlayer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
JWPlayer.PlayerInitializationListener
Fires when the player is initialized
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description boolean
addListener(EventType eventType, EventListener eventListener)
Registers an event listener for a specific player eventboolean
addListeners(EventListener eventListener, EventType... eventTypes)
Registers an event listener for a list of player eventsvoid
allowBackgroundAudio(boolean allowBackgroundAudio)
Toggles background audio on/off for this playerboolean
allowsBackgroundAudio()
void
closeRelatedOverlay()
Closes the related videos overlay if the current video/playlist has a related feed enabled and is shownvoid
closeSharingOverlay()
Deprecated.double
getAdPosition()
Returns the current ad playback position.java.util.List<AudioTrack>
getAudioTracks()
Returns a List with audio tracks from the player.int
getBuffer()
Gets the current buffer percentage of the loaded media.java.util.List<Caption>
getCaptionsList()
Returns a List with captions tracks from the player.PlayerConfig
getConfig()
Returns the current configuration being used by the player.boolean
getControls()
Returns whether or not the built-in controls are currently enabledint
getCurrentAudioTrack()
Returns the index of the currently active audio track.int
getCurrentCaptions()
Returns the index of the currently active captions track.int
getCurrentQuality()
Returns the index of the currently active quality level.double
getDuration()
Returns the duration of the current media.ExoPlayerSettings
getExoPlayerSettings()
ReturnsExoPlayerSettings
reference to manage ExoPlayer's settingsjava.util.List<ExternalMetadata>
getExternalMetadata()
ReturnsExternalMetadata
FriendlyAdObstructions
getFriendlyAdObstructions()
boolean
getMute()
Returns whether the player is currently muted or notdouble
getPlaybackRate()
Returns current playback ratejava.util.List<PlaylistItem>
getPlaylist()
Returns the player's current playlist List.int
getPlaylistIndex()
Returns the index of the currently active item in the playlist.PlaylistItem
getPlaylistItem()
Returns the currently playingPlaylistItem
.PlaylistItem
getPlaylistItem(int index)
Retrieves the same information as getPlaylist(), but for a single playlist itemdouble
getPosition()
Returns the current playback position.java.util.List<QualityLevel>
getQualityLevels()
Returns a list with quality levels from the player.PlayerState
getState()
Returns the player's current playback state.java.lang.String
getVersionCode()
Returns the SDK version.IBaseViewModel
getViewModelForUiGroup(UiGroup id)
ReturnsIBaseViewModel
for the given IdVisualQualityEvent
getVisualQuality()
Returns a VisualQuality object containing information about the current quality of a video stream.int
getVolume()
Returns the volume the player is set toboolean
isControlBarVisible()
Returns whether or not the built-in control bar is visible.void
next()
Tells JW Player to immediately play the next playlist item.boolean
onKeyDown(int keyCode, android.view.KeyEvent event)
Handles keyDown events and calls the appropriate JWPlayer methodsboolean
onKeyUp(int keyCode, android.view.KeyEvent event)
Handles onKeyUp events and calls the appropriate JWPlayer methodsvoid
openRelatedOverlay()
Opens the related videos overlay if the current video/playlist has a related feed enabled If the video is still playing it will pausevoid
openSharingOverlay()
Deprecated.void
pause()
Pauses playback, changing the state of JW Player from playing to paused.void
pauseAd(boolean state)
Used to pause or resume ad playback.void
play()
Sets the play state of the JW Player.void
playAd(java.lang.String... tags)
Used to play an ad right now, which is primarily useful for situations where the built-in ad.void
playlistItem(int index)
Start playback of the playlist item at the specified index.void
removeAllListeners(EventListener eventListener)
Deregister an event listener for all player eventsboolean
removeListener(EventType eventType, EventListener eventListener)
Deregister an event listener for a specific player eventboolean
removeListeners(EventListener eventListener, EventType... eventTypes)
Deregister an event listener for a list of player eventsvoid
removePlaylistItemCallbackListener()
void
seek(double position)
Seeks the currently playing media to the specified position.void
setAnalyticsListener(com.google.android.exoplayer2.analytics.AnalyticsListener listener)
Sets anAnalyticsListener
to receive analytics events.void
setCaptionsRendering(boolean renderCaptions)
Sets our captions renderingvoid
setControls(boolean controls)
Enable the built-in controls by setting them true, disable the controls by setting them false.void
setCurrentAudioTrack(int index)
Change the audio track to the provided index.void
setCurrentCaptions(int index)
Change the visible captions track to the provided index.void
setCurrentCaptions(java.lang.String strLocale)
Change the visible captions track to the RFC 4646 tag provided.void
setCurrentCaptions(java.util.Locale locale)
Change the visible captions track to the locale provided.void
setCurrentQuality(int index)
Change the quality level to the provided index.void
setErrorScreenOkButtonListener(ErrorScreenOkButtonListener errorScreenOkButtonListener)
Adds a listener for handling clicks on the OK button on the Error screenvoid
setExternalLinkHandler(ExternalLinkHandler externalLinkHandler)
Sets the ExternalLinkHandler, you can use this to override the default behavior of opening the browser when a url is requested.void
setExternalMetadata(java.util.List<ExternalMetadata> externalMetadataList)
Sets anExternalMetadata
void
setForceControlsVisibility(boolean visible)
Force controls to be visible, pass false here to revert the controls to their normal behaviorvoid
setMute()
Toggles the mute state of the player.void
setMute(boolean state)
Sets the mute state of the player.void
setPlaybackRate(double playbackRate)
Sets playback ratevoid
setPlaylistItemCallbackListener(VideoPlayerEvents.PlaylistItemCallbackListener listener)
Registers a listener to receive a blocking callback before the start of the next playlist item There can only be 1 listener, additional assignments overwrite the previous listener You can set the listener to null to clear to valuevoid
setup(PlayerConfig playerConfig)
Sets up JW Player with a newPlayerConfig
.void
setVolume(int volume)
Sets the volume of the player.void
skipAd()
Skips an Ad if one is currently playing and skippablevoid
stop()
Stops the player, returning it to the idle state.
-
-
-
Method Detail
-
getVersionCode
java.lang.String getVersionCode()
Returns the SDK version.- Returns:
- The current SDK version.
-
setup
void setup(PlayerConfig playerConfig)
Sets up JW Player with a newPlayerConfig
. This can be used to load media and change options (e.g. captions styling) without creating a new instance of the player.- Parameters:
playerConfig
- The player configuration to use with this JWPlayerView
-
getConfig
PlayerConfig getConfig()
Returns the current configuration being used by the player.- Returns:
- The current configuration.
-
next
void next()
Tells JW Player to immediately play the next playlist item.
-
play
void play()
Sets the play state of the JW Player. Calling play() while media is playing does nothing.
-
pause
void pause()
Pauses playback, changing the state of JW Player from playing to paused. Calling pause() while media is already paused does nothing. Note: When using this method with a non-DVR live stream, the player will appear paused. After this, when play() is called, the stream restarts from the live edge.
-
stop
void stop()
Stops the player, returning it to the idle state.
-
seek
void seek(double position)
Seeks the currently playing media to the specified position.- Parameters:
position
- The position to seek to in seconds from the beginning.
-
setControls
void setControls(boolean controls)
Enable the built-in controls by setting them true, disable the controls by setting them false.- Parameters:
controls
- whether to enable or disable the controls.
-
playAd
void playAd(java.lang.String... tags)
Used to play an ad right now, which is primarily useful for situations where the built-in ad. schedule of JW Player cannot be used. (e.g. for live streaming or dynamic ads for playlist items).Supported for VAST only. Use
#playAd(AdClient, String...)
if you want to play IMA ads.- Parameters:
tags
- The ad tags to play.
-
pauseAd
void pauseAd(boolean state)
Used to pause or resume ad playback.- Parameters:
state
- Set whether or not the ad playback should be paused.
-
setExternalLinkHandler
void setExternalLinkHandler(ExternalLinkHandler externalLinkHandler)
Sets the ExternalLinkHandler, you can use this to override the default behavior of opening the browser when a url is requested.- Parameters:
externalLinkHandler
- theExternalLinkHandler
to use for opening URLs.
-
openRelatedOverlay
void openRelatedOverlay()
Opens the related videos overlay if the current video/playlist has a related feed enabled If the video is still playing it will pause
-
closeRelatedOverlay
void closeRelatedOverlay()
Closes the related videos overlay if the current video/playlist has a related feed enabled and is shown
-
openSharingOverlay
@Deprecated void openSharingOverlay()
Deprecated.Opens the sharing plugin. This will also pause content if it is triggered during playback.
-
closeSharingOverlay
@Deprecated void closeSharingOverlay()
Deprecated.Closes the sharing plugin if it is opened. This will resume playback if the sharing overlay was triggered during content.
-
playlistItem
void playlistItem(int index)
Start playback of the playlist item at the specified index.- Parameters:
index
- The index of a playlist item you wish to play.
-
setCurrentQuality
void setCurrentQuality(int index)
Change the quality level to the provided index. The index must be within the list provided by getQualityLevels().- Parameters:
index
- Index of the quality level to switch to.
-
setPlaybackRate
void setPlaybackRate(double playbackRate)
Sets playback rate- Parameters:
playbackRate
- The playback rate to be set
-
setCaptionsRendering
void setCaptionsRendering(boolean renderCaptions)
Sets our captions rendering- Parameters:
renderCaptions
- set whether or not to disable our captions rendering
-
setCurrentCaptions
void setCurrentCaptions(int index)
Change the visible captions track to the provided index. The index must be within the list provided by getCaptionsList.Note an index of 0 always turns the captions Off.
- Parameters:
index
- The index of the caption track to switch to.
-
setCurrentCaptions
void setCurrentCaptions(java.lang.String strLocale)
Change the visible captions track to the RFC 4646 tag provided.- Parameters:
strLocale
- The string locale in RFC 4646 tag
-
setCurrentCaptions
void setCurrentCaptions(java.util.Locale locale)
Change the visible captions track to the locale provided.- Parameters:
locale
- The Locale object to defined current caption
-
setCurrentAudioTrack
void setCurrentAudioTrack(int index)
Change the audio track to the provided index. The index must be within the list provided by getAudioTracks().- Parameters:
index
- Index of the audio track to switch to.
-
setMute
void setMute()
Toggles the mute state of the player.
-
setMute
void setMute(boolean state)
Sets the mute state of the player.- Parameters:
state
- If true, mute the player. If false, unmute the player.
-
setVolume
void setVolume(int volume)
Sets the volume of the player.- Parameters:
volume
- Volume to use for this player, can be 0 to 100
-
setForceControlsVisibility
void setForceControlsVisibility(boolean visible)
Force controls to be visible, pass false here to revert the controls to their normal behavior
-
setAnalyticsListener
void setAnalyticsListener(com.google.android.exoplayer2.analytics.AnalyticsListener listener)
Sets anAnalyticsListener
to receive analytics events.- Parameters:
listener
- The listener to be added.
-
getState
PlayerState getState()
Returns the player's current playback state.- Returns:
- The player's current playback state.
-
getPosition
double getPosition()
Returns the current playback position.- Returns:
- The current playback position in seconds, or -1 if not available.
-
getAdPosition
double getAdPosition()
Returns the current ad playback position.- Returns:
- The current ad playback position in seconds, or -1 if not available.
-
getDuration
double getDuration()
Returns the duration of the current media.- Returns:
- The current media duration in seconds, or -1 if not available.
-
getPlaylist
java.util.List<PlaylistItem> getPlaylist()
Returns the player's current playlist List.- Returns:
- The player's curent playlist.
-
getPlaylistIndex
int getPlaylistIndex()
Returns the index of the currently active item in the playlist.- Returns:
- The index of the currently active item in the playlist.
-
getPlaylistItem
PlaylistItem getPlaylistItem(int index)
Retrieves the same information as getPlaylist(), but for a single playlist item- Returns:
- Retrieves the same information as getPlaylist(), but for a single playlist item
-
getPlaylistItem
PlaylistItem getPlaylistItem()
Returns the currently playingPlaylistItem
.- Returns:
- The currently playing
PlaylistItem
.
-
getBuffer
int getBuffer()
Gets the current buffer percentage of the loaded media.- Returns:
- A percentage (0-100) of the video's current loaded amount
-
getQualityLevels
java.util.List<QualityLevel> getQualityLevels()
Returns a list with quality levels from the player.- Returns:
- List of quality levels from the player.
-
getCurrentQuality
int getCurrentQuality()
Returns the index of the currently active quality level.- Returns:
- The index of the currently active quality level.
-
getPlaybackRate
double getPlaybackRate()
Returns current playback rate- Returns:
- The playback rate
-
getVisualQuality
VisualQualityEvent getVisualQuality()
Returns a VisualQuality object containing information about the current quality of a video stream.- Returns:
- an object containing information about the current quality, or null if the information is not available.
-
getCaptionsList
java.util.List<Caption> getCaptionsList()
Returns a List with captions tracks from the player.- Returns:
- List with captions tracks from the player.
-
getCurrentCaptions
int getCurrentCaptions()
Returns the index of the currently active captions track. Note the captions are Off if the index is 0.- Returns:
- The index of the currently active captions track.
-
getCurrentAudioTrack
int getCurrentAudioTrack()
Returns the index of the currently active audio track.- Returns:
- Index of the currently active audio track.
-
getAudioTracks
java.util.List<AudioTrack> getAudioTracks()
Returns a List with audio tracks from the player.- Returns:
- List with audio tracks from the player.
-
getMute
boolean getMute()
Returns whether the player is currently muted or not- Returns:
- true if the player has been muted, false if it isn't.
-
getVolume
int getVolume()
Returns the volume the player is set to- Returns:
- the volume the player is set to, from 0 to 100
-
getControls
boolean getControls()
Returns whether or not the built-in controls are currently enabled- Returns:
- true if the built-in controls are currently enabled
-
isControlBarVisible
boolean isControlBarVisible()
Returns whether or not the built-in control bar is visible.Note: this might not give the expected result if you are using a custom CSS skin that alters the behavior of the control bar.
- Returns:
- true if the built-in control bar is visible.
-
getExternalMetadata
java.util.List<ExternalMetadata> getExternalMetadata()
ReturnsExternalMetadata
- Returns:
- Current ExternalMetadata for this playlistItem
-
setExternalMetadata
void setExternalMetadata(java.util.List<ExternalMetadata> externalMetadataList)
Sets anExternalMetadata
- Parameters:
externalMetadataList
-
-
getFriendlyAdObstructions
FriendlyAdObstructions getFriendlyAdObstructions()
- Returns:
- the
FriendlyAdObstructions
object associated to this player
-
getExoPlayerSettings
@NonNull ExoPlayerSettings getExoPlayerSettings()
ReturnsExoPlayerSettings
reference to manage ExoPlayer's settings- Returns:
- ExoPlayer's settings
-
getViewModelForUiGroup
IBaseViewModel getViewModelForUiGroup(UiGroup id)
ReturnsIBaseViewModel
for the given Id- Returns:
- A viewmodel
-
skipAd
void skipAd()
Skips an Ad if one is currently playing and skippable
-
setPlaylistItemCallbackListener
void setPlaylistItemCallbackListener(VideoPlayerEvents.PlaylistItemCallbackListener listener)
Registers a listener to receive a blocking callback before the start of the next playlist item There can only be 1 listener, additional assignments overwrite the previous listener You can set the listener to null to clear to value
-
removePlaylistItemCallbackListener
void removePlaylistItemCallbackListener()
-
setErrorScreenOkButtonListener
void setErrorScreenOkButtonListener(ErrorScreenOkButtonListener errorScreenOkButtonListener)
Adds a listener for handling clicks on the OK button on the Error screen
-
addListener
boolean addListener(@NonNull EventType eventType, @NonNull EventListener eventListener)
Registers an event listener for a specific player event- Parameters:
eventType
- The event type to listen toeventListener
- The listener that will handle the event- Returns:
- true if adding of listener was successful
-
addListeners
boolean addListeners(@NonNull EventListener eventListener, @NonNull EventType... eventTypes)
Registers an event listener for a list of player events- Parameters:
eventListener
- The listener that will handle the eventseventTypes
- The event types to listen to- Returns:
- true if adding of listeners was successful
-
removeListener
boolean removeListener(@NonNull EventType eventType, @NonNull EventListener eventListener)
Deregister an event listener for a specific player event- Parameters:
eventType
- The event type to stop listening toeventListener
- The listener that will handle the event- Returns:
- true if removal of the listener was successful
-
removeListeners
boolean removeListeners(@NonNull EventListener eventListener, @NonNull EventType... eventTypes)
Deregister an event listener for a list of player events- Parameters:
eventListener
- The listener that will handle the eventseventTypes
- The event types to stop listening to- Returns:
- true if removal of the listeners was successful
-
removeAllListeners
void removeAllListeners(@NonNull EventListener eventListener)
Deregister an event listener for all player events- Parameters:
eventListener
- The listener that will be deregistered
-
allowBackgroundAudio
void allowBackgroundAudio(boolean allowBackgroundAudio)
Toggles background audio on/off for this player- Parameters:
allowBackgroundAudio
- whether or not to allow background audio
-
allowsBackgroundAudio
boolean allowsBackgroundAudio()
- Returns:
- allowBackgroundAudio value
-
onKeyDown
boolean onKeyDown(int keyCode, android.view.KeyEvent event)
Handles keyDown events and calls the appropriate JWPlayer methods- Parameters:
keyCode
- The keyCode of the key pressed
-
onKeyUp
boolean onKeyUp(int keyCode, android.view.KeyEvent event)
Handles onKeyUp events and calls the appropriate JWPlayer methods- Parameters:
keyCode
- The keyCode of the key pressed
-
-