Available Methods

Available methods

List of available methods in the BridPlayer interface:


    /**
     * Starts video playback. If a video is already playing, it continues from the current position.
     */
    void play();

    /**
     * Pauses the currently playing video. If an ad is playing, this call is ignored.
     */
    void pause();

    /**
     * Hides the video poster.
     */
    void hidePoster();

    /**
     * Shows the video poster.
     */
    void showPoster();

    /**
     * Shows the playlist UI. 
     * @param isPlayButtonChange If true, the play button will change to a replay button.
     */
    void showPlaylist(boolean isPlayButtonChange);

    /**
     * Releases resources used by the ad player.
     */
    void releaseAdPlayer();

    /**
     * Sets a listener for player events.
     * @param l The listener to set.
     */
    void setBridListener(BridPlayerListener l);

    /**
     * Checks if an advertisement is currently playing.
     * @return True if an ad is playing, false otherwise.
     */
    boolean isPlayingAd();

    /**
     * Checks if the player is currently paused.
     * @return True if paused, false otherwise.
     */
    boolean isPaused();

    /**
     * Checks if the video is set to repeat.
     * @return True if repeat is enabled, false otherwise.
     */
    boolean isRepeated();

    /**
     * Gets the current playback position of the video.
     * @return The current position in milliseconds.
     */
    long getCurrentPosition();

    /**
     * Gets the duration of the currently loaded video.
     * @return The duration in milliseconds.
     */
    long getDuration();

    /**
     * Checks if the player is in fullscreen mode.
     * @return True if in fullscreen mode, false otherwise.
     */
    boolean isFullscreen();

    /**
     * Checks if the player is muted.
     * @return True if muted, false otherwise.
     */
    boolean isMuted();

    /**
     * Enables or disables experimental support for VPAID ads. This setting should be applied before loading any video or playlist content.
     * @param vpaid A boolean indicating whether VPAID support should be enabled.
     */
    void useVPAIDSupport(boolean vpaid);

    /**
     * Checks whether VPAID support is currently enabled.
     * @return True if VPAID support is enabled, false otherwise.
     */
    boolean isVpaidEnabled();

    /**
     * Navigates to the previous video in the playlist. This method will not function if an ad is currently playing.
     */
    void previous();

    /**
     * Navigates to the next video in the playlist. This method will not function if an ad is currently playing.
     */
    void next();

    /**
     * Toggles the player between fullscreen and windowed mode.
     * @param on A boolean indicating whether to enter (true) or exit (false) fullscreen mode.
     */
    void setFullScreen(boolean on);

    /**
     * Mutes or unmutes the player's audio.
     * @param mute A boolean indicating whether the audio should be muted (true) or unmuted (false).
     */
    void setMute(boolean mute);


    /**
     * Resumes video playback from the current position. This can be used to resume after a pause.
     */
    void resume();

    /**
     * Sets the autoplay option for the player. If enabled, the next video will automatically play when the current video ends.
     * @param autoplay A boolean indicating whether autoplay should be enabled (true) or disabled (false).
     */
    void setAutoPlay(boolean autoplay);

    /**
     * Resets the player to its initial state. This can be used to prepare the player for a new video or playlist.
     */
    void reset();

    /**
     * Releases resources used by the player. This should be called when the player is no longer needed to free up resources immediately.
     */
    void release();

    /**
     * Fast forwards the currently playing video. The behavior and speed of fast forwarding are implementation-specific.
     */
    void fastForward();

    /**
     * Rewinds the currently playing video. The behavior and speed of rewinding are implementation-specific.
     */
    void fastBack();

    /**
     * Shows the player controls. This can be used to ensure that controls are visible, for example, when the user interacts with the player.
     */
    void showControls();

    /**
     * Hides the player controls. This can be used for a cleaner viewing experience without on-screen distractions.
     */
    void hideControls();


    /**
     * Sets the icon for the fullscreen toggle button.
     * @param fullscreenIcon A drawable resource ID for the fullscreen icon.
     */
    void setFullscreenIcon(@DrawableRes int fullscreenIcon);

    /**
     * Sets the color for the play and pause button.
     * @param playPauseIcon A color resource ID for the play/pause icon.
     */
    void setPlayPauseIcon(@ColorRes int playPauseIcon);

    /**
     * Sets the icon for the mute button.
     * @param muteIcon A drawable resource ID for the mute icon.
     */
    void setMuteIcon(@DrawableRes int muteIcon);

    /**
     * Sets the icon for the unmute button.
     * @param unmuteIcon A drawable resource ID for the unmute icon.
     */
    void setUnmuteIcon(@DrawableRes int unmuteIcon);

    /**
     * Sets the icon for the playlist button.
     * @param playlistIcon A drawable resource ID for the playlist icon.
     */
    void setPlaylistIcon(@DrawableRes int playlistIcon);

    /**
     * Sets the icon for the share button.
     * @param shareIcon A drawable resource ID for the share icon.
     */
    void setShareIcon(@DrawableRes int shareIcon);

    /**
     * Sets the icon for the settings button.
     * @param settingsIcon A drawable resource ID for the settings icon.
     */
    void setSettingsIcon(@DrawableRes int settingsIcon);

    /**
     * Sets the colors for various components of the timeline (seek bar), including played, unplayed, buffered segments, and the scrubber.
     * @param playedColor The color for played segments.
     * @param unplayedColor The color for unplayed segments.
     * @param bufferedColor The color for buffered segments.
     * @param scrubberColor The color for the scrubber.
     */
    void setTimelineColors(@ColorRes int playedColor, @ColorRes int unplayedColor, @ColorRes int bufferedColor, @ColorRes int scrubberColor);

    /**
     * Sets the icon for closing the fullscreen mode.
     * @param fullscreenCloseIcon A drawable resource ID for the fullscreen close icon.
     */
    void setFullscreenCloseIcon(@DrawableRes int fullscreenCloseIcon);

    /**
     * Sets the control icons for TV mode, such as the forward icon.
     * @param forwardIcon A drawable resource ID for the forward icon.
     */
    void setTVControls(@DrawableRes int forwardIcon);

    /**
     * Sets the drawable used for focus highlights.
     * @param focusDrawable A drawable resource ID for the focus highlight.
     */
    void setFocusDrawable(@DrawableRes int focusDrawable);

    /**
     * Sets the icon for closing the playlist.
     * @param exitIcon A drawable resource ID for the playlist close icon.
     */
    void setPlaylistCloseIcon(@DrawableRes int exitIcon);

    /**
     * Closes the ad loading dialog. This method can be used after an ad has been loaded or if the ad loading needs to be aborted.
     */
    void closeAdLoading();


    /**
     * Shows a view indicating a network error. This can be used to inform the user when the player cannot load content due to network issues.
     */
    void showNetworkErrorView();

    /**
     * Dismisses the view indicating a network error. This can be used once network connectivity is restored or if the user wants to attempt reloading content.
     */
    void dismissNetworkErrorView();

    /**
     * Enables or disables controls for advertisements. This can be used to provide a custom user experience during ad playback.
     * @param isEnabled True to enable ad controls, false to disable them.
     */
    void enableAdControls(boolean isEnabled);

    /**
     * Checks if advertisement controls are enabled.
     * @return True if ad controls are enabled, false otherwise.
     */
    boolean isAdControlsEnabled();

    /**
     * Enables or disables autoplay functionality. This setting influences whether the player will automatically start playing the next video or playlist item.
     * @param isAutoplay True to enable autoplay, false to disable it.
     */
    void enableAutoplay(boolean isAutoplay);

    /**
     * Sets the corner radius for the player view. This can be used for UI customization, especially when embedding the player in layouts with rounded corners.
     * @param cornerRadius The corner radius in pixels.
     */
    void setCornerRadius(int cornerRadius);

    /**
     * Checks if autoplay is enabled for the player.
     * @return True if autoplay is enabled, false otherwise.
     */
    boolean isAutoplayEnabled();

    /**
     * An alternative method to check if autoplay is enabled, potentially offering different internal logic or redundancy.
     * @return True if autoplay is enabled, false otherwise.
     */
    boolean isAutoplay();

    /**
     * Sets the color of the credits label. This can be used for UI customization to match the player controls with the application's theme.
     * @param labelColor The color for the credits label, specified as a hexadecimal string without the '#' symbol.
     */
    void setCreditsLabelColor(String labelColor);

    /**
     * Reinitializes the poster view with a new video list and index. This can be used to update the poster when changing videos or playlists.
     * @param videoList The new list of videos.
     * @param index The index of the video in the list to use for the poster.
     */
    void reinitializePoster(ArrayList<Video> videoList, int index);

    /**
     * Sets a reference string for the player. This can be used to tag or identify the player instance within the application.
     * @param playerReference A string to use as the player reference.
     */
    void setPlayerReference(String playerReference);

    /**
     * Retrieves the player reference string.
     * @return The player reference string.
     */
    String getPlayerReference();

    /**
     * Sets the language for the player. This can affect UI elements, subtitles, and other language-specific features.
     * @param countryCode The ISO 3166-1 alpha-2 country code representing the language.
     */
    void setPlayerLanguage(String countryCode);

    /**
     * Sets the number of seconds to seek when the user triggers a seek operation. This can customize the seek behavior for fast forward and rewind.
     * @param seekSeconds The number of seconds to seek.
     */
    void setSeekSeconds(int seekSeconds);

    /**
     * Configures the type of preview shown during seeking. This can enhance the user experience by providing visual feedback while seeking.
     * @param typeOfPreview Defines the preview type: 0 for disabled, 1 for enabled, and 2 for enabled only in fullscreen mode.
     */
    void setSeekPreview(int typeOfPreview);

    /**
     * Simulates a play button click. This can be used to programmatically start video playback, mimicking user interaction.
     */
    void clickPlay();

    /**
     * Enters Picture-in-Picture (PiP) mode. This is useful for providing a floating video window on devices that support PiP.
     */
    void enterPictureInPictureMode();

    /**
     * Handles changes in Picture-in-Picture mode, such as entering or exiting PiP. This can be used to adjust the player or application UI in response to PiP events.
     * @param isInPictureInPictureMode A boolean indicating whether the player is in PiP mode.
     * @param newConfig The new Configuration object, which may contain updated screen dimensions or orientation.
     */
    void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig);
}



BridPoster

This class can be used if you want to show fake player (poster image with play button and video title). You might find it useful in situations when you plan to launch video in a new activity, and don't need full featured player there. Consider using this approach when you need to show several players in the same activity or fragment.

BridPoster bridPoster = new BridPoster(this, videoHolder);
bridPoster.loadVideo(playerID, videoID);
bridPoster.setListener(new BridPoster.BridPosterListener() {
    if (event.equals(BridPoster.EVENT_PLAY_CLICKED)) {
        int playerId = data.getInt("playerId");
        int videoId = data.getInt("videoId");
        int playlistId = data.getInt("playlistId");
    }
});
val bridPoster = BridPoster(this, videoHolder)

bridPoster.loadVideo(playerID, videoID)

bridPoster.setListener(object : BridPoster.BridPosterListener {
override fun onEvent(event: String, data: Bundle) {
  if (event == BridPoster.EVENT_PLAY_CLICKED) {
  val playerId = data.getInt("playerId")
  val videoId = data.getInt("videoId")
  val playlistId = data.getInt("playlistId")
		}
	}
})

Specify callback on specific event

You can specify callback function which will be executed when specific event occured in the player.
Here is the complete list of supported callbacks:

Specify callback when loadVideo function is executed

public void loadVideo(int playerId, int videoId, FetchData callback)

Specify callback when loadPlaylist function is executed

public void loadPlaylist(int playerId, int playlistId, FetchData callback)

Specify callback when loadPlaylistForChannel function is executed

public void loadPlaylistForChannel(int playerId, int channelId, int page, int item, FetchData callback)

Specify callback when loadLatestPlaylists function is executed

public void loadLatestPlaylists(int playerId, int page, int item, FetchData callback)

Specify callback when loadPlaylistForTag function is executed

public void loadPlaylistForTag(int playerId, String tagType, int page, int item, FetchData callback) 

What’s Next