Interface JWPlayer


public interface JWPlayer
  • Method Details

    • getVersionCode

      String getVersionCode()
      Returns the SDK version.
      Returns:
      The current SDK version.
    • setup

      void setup(PlayerConfig playerConfig)
      Sets up JW Player with a new PlayerConfig. 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.
    • setFullscreen

      void setFullscreen(boolean state, boolean allowRotation)
      Enables or disables fullscreen mode.
      Parameters:
      state - Whether the video player should run in fullscreen mode.
      allowRotation - Whether to allow rotation to enter or exit fullscreen, false to only allow portrait/landscape change via setFullscreen().
    • 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(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).

      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 - the ExternalLinkHandler 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
    • 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(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(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
    • isForceControlsVisibility

      boolean isForceControlsVisibility()
      Returns if force controls to be visible is active
    • setAnalyticsListener

      void setAnalyticsListener(AnalyticsListener listener)
      Sets an AnalyticsListener 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.
    • getFullscreen

      boolean getFullscreen()
      Returns whether the player is currently in fullscreen.
      Returns:
      Whether the video player is running in fullscreen mode.
    • getPlaylist

      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 playing PlaylistItem.
      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

      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.
    • isCaptionsRendering

      boolean isCaptionsRendering()
      Returns a boolean of whether or not captions rendering is on/off
      Returns:
      boolean of whether or not captions rendering is on/off
    • getCaptionsList

      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

      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.

      Returns:
      true if the built-in control bar is visible.
    • getExternalMetadata

      List<ExternalMetadata> getExternalMetadata()
      Returns:
      Current ExternalMetadata for this playlistItem
    • setExternalMetadata

      void setExternalMetadata(List<ExternalMetadata> externalMetadataList)
      Parameters:
      externalMetadataList -
    • getFriendlyAdObstructions

      FriendlyAdObstructions getFriendlyAdObstructions()
      Returns:
      the FriendlyAdObstructions object associated to this player
    • setFullscreenHandler

      void setFullscreenHandler(FullscreenHandler fullscreenHandler)
      Replaces the default FullscreenHandler with the one provided.
      Parameters:
      fullscreenHandler - the fullscreen handler that should take care of fullscreening.
    • getExoPlayerSettings

      ExoPlayerSettings getExoPlayerSettings()
      Returns ExoPlayerSettings reference to manage ExoPlayer's settings
      Returns:
      ExoPlayer's settings
    • getViewModelForUiGroup

      IBaseViewModel getViewModelForUiGroup(UiGroup id)
      Returns IBaseViewModel for the given Id
      Returns:
      A viewmodel
    • skipAd

      void skipAd()
      Skips an Ad if one is currently playing and skippable
    • skipAdBreak

      void skipAdBreak()
      If an ad break is currently playing, discard it and resume content. Otherwise, ignore the next scheduled ad break.
    • openAdClickthrough

      void openAdClickthrough()
      Opens an ad's clickthrough URL if one is available
    • 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()
    • addListener

      boolean addListener(EventType eventType, EventListener eventListener)
      Registers an event listener for a specific player event
      Parameters:
      eventType - The event type to listen to
      eventListener - The listener that will handle the event
      Returns:
      true if adding of listener was successful
    • addListeners

      boolean addListeners(EventListener eventListener, EventType... eventTypes)
      Registers an event listener for a list of player events
      Parameters:
      eventListener - The listener that will handle the events
      eventTypes - The event types to listen to
      Returns:
      true if adding of listeners was successful
    • removeListener

      boolean removeListener(EventType eventType, EventListener eventListener)
      Deregister an event listener for a specific player event
      Parameters:
      eventType - The event type to stop listening to
      eventListener - The listener that will handle the event
      Returns:
      true if removal of the listener was successful
    • removeListeners

      boolean removeListeners(EventListener eventListener, EventType... eventTypes)
      Deregister an event listener for a list of player events
      Parameters:
      eventListener - The listener that will handle the events
      eventTypes - The event types to stop listening to
      Returns:
      true if removal of the listeners was successful
    • removeAllListeners

      void removeAllListeners(EventListener eventListener)
      Deregister an event listener for all player events
      Parameters:
      eventListener - The listener that will be deregistered
    • allowsBackgroundAudio

      boolean allowsBackgroundAudio()
    • registerActivityForPip

      boolean registerActivityForPip(Activity activity, ActionBar actionBar)
      Register activity for picture in picture feature
      Parameters:
      activity - The activity that hosts the player
      actionBar - The appCompact Action Bar of the activity (getSupportActionBar())
      Returns:
      Upon successful registration, true is returned
    • deregisterActivityForPip

      boolean deregisterActivityForPip()
      Deregister picture in picture feature
      Returns:
      upon successful deregistration, true is returned
    • enterPictureInPictureMode

      boolean enterPictureInPictureMode()
      Enter Picture in picture mode
      Returns:
      true if successfully enters Picture in picture mode
    • exitPictureInPictureMode

      boolean exitPictureInPictureMode()
      Exit Picture in picture mode to the activity registered
      Returns:
      true if successfully exits picture in picture mode
    • isInPictureInPictureMode

      boolean isInPictureInPictureMode()
      Check if player is in picture in picture mode
      Returns:
      true if in picture in picture mode
    • onPictureInPictureModeChanged

      void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, android.content.res.Configuration newConfig)
      Should be called at Activity.onPictureInPictureModeChanged() to relay the picture in picture mode information to the SDK
      Parameters:
      isInPictureInPictureMode - informs the sdk if the video is in PiP mode. true if it is.
      newConfig - Informs the SDK of any configuration of PiP mode
    • setPipOnBackground

      void setPipOnBackground(boolean pipOnBackground)
      Controls whether or not to pip the jwplayer when the user hits the home button.
      Parameters:
      pipOnBackground - The new value for pipOnBackground
    • setPipAspectRatio

      void setPipAspectRatio(Rational pipAspectRatio)
    • setPipSourceRectHint

      void setPipSourceRectHint(Rect pipSourceRectHint)
      Sets the source rect hint that will be used for PiP mode. If none is provided a default will be generated based on the player view
      Parameters:
      pipSourceRectHint - the Rect to use for the source rect hint
    • allowBackgroundAudio

      void allowBackgroundAudio(boolean allowBackgroundAudio)
      Toggles background audio on/off for this player
      Parameters:
      allowBackgroundAudio - whether or not to allow background audio
    • allowFullscreenPortrait

      void allowFullscreenPortrait(boolean canFullscreenPortrait)
      Allows the player to show content in full-screen portrait Best usage is to change this flag based on the content playing and it's desired orientation If enabled, full-screen portrait will be favored regardless of the media being played, and if the device orientation is unlocked, rotation will switch between portrait and landscape full-screen Default is false, and can be ignored if a custom FullscreenHandler is supplied to the player
      Parameters:
      canFullscreenPortrait - whether or not to allow full screen portrait
    • getAllowFullscreenPortrait

      boolean getAllowFullscreenPortrait()
      Return if the player allows full-screen portrait
      Returns:
      full-screen Portrait