Skip to main content

MediaPlayer

MediaPlayer Class

com.kollus.sdk.media.MediaPlayer

The core playback engine class of the SDK that handles content playback, display output control, subtitle management, and various multimedia events.

Classes & Interfaces

  • interface APP_STATUS
  • enum EXTERNAL_DISPLAY_MODE
  • enum MediaRouteState
  • interface OnCompletionListener
  • interface OnErrorListener
  • interface OnExternalDisplayDetectListener
  • interface OnInfoListener
  • interface OnMediaRouteInfoListener
  • interface OnPreparedListener
  • interface OnSeekCompleteListener
  • interface OnTimedTextDetectListener
  • interface OnTimedTextListener
  • interface OnVideoSizeChangedListener
  • class TMCMReceiver
  • class TrackInfo

Public Methods

  • MediaPlayer(Context context, KollusStorage storage, int port)
  • void addTimedTextSource(boolean bSubTimedText, String path) throws IOException, IllegalArgumentException, IllegalStateException, RuntimeException
  • void addTimedTextSource(Context context, boolean bSubTimedText, Uri uri) throws IOException, IllegalArgumentException, IllegalStateException
  • void deleteKollusBookmark(int position) throws IllegalStateException
  • void deselectTrack(boolean bSubTimedText, int index) throws IllegalStateException
  • void destroyDisplay()
  • int getBandwidth()
  • int getCachedDuration()
  • int getCurrentPosition()
  • int getDownloadRate()
  • int getDuration()
  • String getErrorString(int errorCode)
  • boolean getKollusContent(KollusContent content) throws IllegalStateException
  • int getPlayAt()
  • String getPlayerName()
  • MediaPlayerBase.TrackInfo[] getTrackInfo() throws IllegalStateException
  • String getVersion()
  • String getVideoCodecName()
  • int getVideoHeight()
  • int getVideoWidth()
  • boolean isAiPlaybackRateEnabled()
  • boolean isLooping()
  • boolean isPlaying()
  • void pause() throws IllegalStateException
  • void prepareAsync()
  • void release()
  • void seekTo(int msec) throws IllegalStateException
  • void seekToExact(int msec) throws IllegalStateException
  • void selectTrack(boolean bSubTimedText, int index) throws IllegalStateException
  • void setAiPlaybackRateEnable(boolean enable)
  • void setAppStatus(@APP_STATUS int status)
  • void setAudioDelay(int timeMs)
  • void setBandwidth(int bandwidth)
  • void setBandwidthName(String bandwidthName)
  • boolean setBufferingRatio(int ratio)
  • void setCaptureDetectLister(CaptureDetectLister listener)
  • void setDataSourceByKey(String mediaContentKey, String extraDrmParam)
  • void setDataSourceByUrl(String path, String extraDrmParam)
  • void setDisplay(SurfaceHolder sh)
  • void setEmulatorCheckerListener(EmulatorCheckerListener listener)
  • void setInitialBandwidth(int bandwidth)
  • void selectAudio (String language)
  • void setKollusPlayerBookmarkListener(KollusPlayerBookmarkListener listener)
  • void setKollusPlayerLMSListener(KollusPlayerLMSListener listener)
  • void setLastOffsetTime(int lastOffsetTimeMs)
  • void setLmsOffDownloadContent(boolean bOn)
  • void setLooping(boolean looping)
  • void setMinDurationForQualityIncreaseMs(int msec)
  • void setMute(boolean mute)
  • boolean setNetworkTimeout(int timeout)
  • void setNotifyLastReport(boolean bOn)
  • void setOnCompletionListener(OnCompletionListener listener)
  • void setOnErrorListener(OnErrorListener listener)
  • void setOnExternalDisplayDetectListener(OnExternalDisplayDetectListener listener)
  • void setOnInfoListener(OnInfoListener listener)
  • void setOnMediaRouteInfoListener(OnMediaRouteInfoListener listener)
  • void setOnPreparedListener(OnPreparedListener listener)
  • void setOnSeekCompleteListener(OnSeekCompleteListener listener)
  • void setOnTimedTextDetectListener(OnTimedTextDetectListener listener)
  • void setOnTimedTextListener(OnTimedTextListener listener)
  • void setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener)
  • boolean setPlayingRate(float playing_rate) throws IllegalStateException
  • void setRemoteMediaRouteInfo(String castNameSpace)
  • void setScreenOnWhilePlaying(boolean screenOn)
  • void setSurface(Surface surface)
  • void setVideoRending(boolean bRendering)
  • void skip()
  • void start() throws IllegalStateException
  • void stop() throws IllegalStateException
  • boolean supportPlaybackrateControl()
  • void updateKollusBookmark(int position, String label) throws IllegalStateException

Static Public Properties

  • static final String VERSION = "2.0.19_r3"
  • static final int MEDIA_ERROR_UNKNOWN = 1
  • static final int APP_STATUS_BACKGROUND = 1
  • static final int APP_STATUS_FOREGROUND = 2
  • static final int MEDIA_INFO_FRAME_RATE = 7
  • static final int MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200
  • static final int QUICK = 1
  • static final int EXACT = 2
  • static final String CAST_NAME_SPACE = "urn:x-cast:com.kollus.cast"
  • static final String CAST_APP_ID = "E956F6B0"

Protected Methods

  • void setKollusStorage(KollusStorage storage)

Constructors & Destructors

com.kollus.sdk.media.MediaPlayer.MediaPlayer(Context context, KollusStorage storage, int port)

Creates a player instance.

  • Parameters
    • context: Context instance
    • storage: KollusStorage instance
    • port: Server port number required for internal player communication

Method Details

void com.kollus.sdk.media.MediaPlayer.addTimedTextSource(boolean bSubTimedText, String path) throws IOException, IllegalArgumentException, IllegalStateException, RuntimeException

Sets a subtitle via an HTTP URL path.

  • Parameters
    • bSubTimedText: Whether a sub subtitle is present
    • path: HTTP URL path of the subtitle file
  • See Also: OnTimedTextDetectListener

void com.kollus.sdk.media.MediaPlayer.addTimedTextSource(Context context, boolean bSubTimedText, Uri uri) throws IOException, IllegalArgumentException, IllegalStateException

Sets a subtitle via an Android URI.

  • Parameters
    • context: Application context
    • bSubTimedText: Whether a sub subtitle is present
    • uri: URI path of the subtitle file

void com.kollus.sdk.media.MediaPlayer.deleteKollusBookmark(int position) throws IllegalStateException

Deletes bookmark information at a specific position. The result of the deletion is returned via the onBookmarkDeleted callback.

  • Parameters
    • position: Position of the bookmark to delete (ms)

void com.kollus.sdk.media.MediaPlayer.deselectTrack(boolean bSubTimedText, int index) throws IllegalStateException

Deselects a specific media track that was selected via the selectTrack method.

  • Parameters
    • bSubTimedText: Whether it is a sub subtitle track
    • index: Index of the track to deselect

void com.kollus.sdk.media.MediaPlayer.destroyDisplay()

Call at the destroy point of the video output surface (Surface or SurfaceHolder) to release resources.


int com.kollus.sdk.media.MediaPlayer.getBandwidth()

Retrieves the bandwidth information of the content currently being downloaded during Adaptive Bitrate(ABR) playback in an MPEG-DASH environment.

  • Returns: Bandwidth (the currently downloading bandwidth value)

int com.kollus.sdk.media.MediaPlayer.getCachedDuration()

Retrieves the duration of the video currently cached in the buffer during streaming playback.

  • Returns: Cached video duration (ms)

int com.kollus.sdk.media.MediaPlayer.getCurrentPosition()

Retrieves the current playback position.

  • Returns: Current playback position (ms)

int com.kollus.sdk.media.MediaPlayer.getDownloadRate()

Retrieves the current data download speed in an MPEG-DASH playback environment.

  • Returns: Download speed

int com.kollus.sdk.media.MediaPlayer.getDuration()

Retrieves the total duration of the content currently playing.

  • Returns: Total content duration (ms)

String com.kollus.sdk.media.MediaPlayer.getErrorString(int errorCode)

Returns the message string corresponding to an error code.

  • Parameters
    • errorCode: Error code
  • Returns: String corresponding to the error code

boolean com.kollus.sdk.media.MediaPlayer.getKollusContent(KollusContent content) throws IllegalStateException

Retrieves detailed information about the content currently playing.

  • Parameters
    • content: Instance to copy the content information into
  • Returns: Whether the information was retrieved successfully

int com.kollus.sdk.media.MediaPlayer.getPlayAt()

Retrieves the resume position information. This is related to features such as nscreen synchronization.

  • Returns: Last saved viewing position (ms)

String com.kollus.sdk.media.MediaPlayer.getPlayerName()

Retrieves the name of the actual player created via MediaPlayerFactory.

  • Returns: Player name

MediaPlayerBase.TrackInfo[] com.kollus.sdk.media.MediaPlayer.getTrackInfo() throws IllegalStateException

Retrieves the track information of the content currently playing.

  • Returns: Array of track information

String com.kollus.sdk.media.MediaPlayer.getVersion()

Retrieves the player version.

  • Returns: Player version

String com.kollus.sdk.media.MediaPlayer.getVideoCodecName()

Retrieves the video codec name. Primarily used to verify whether a hardware (HW) codec is being used.

  • Returns: Video codec name

int com.kollus.sdk.media.MediaPlayer.getVideoHeight()

Retrieves the height of the content. Can be called normally after receiving the onPrepared response.

  • Returns: Video height (px)

int com.kollus.sdk.media.MediaPlayer.getVideoWidth()

Retrieves the width of the content. Can be called normally after receiving the onPrepared response.

  • Returns: Video width (px)

boolean com.kollus.sdk.media.MediaPlayer.isAiPlaybackRateEnabled()

Checks whether the AI Speed feature is enabled for the current content.

  • Returns
    • true: Enabled
    • false: Disabled

boolean com.kollus.sdk.media.MediaPlayer.isLooping()

Checks whether repeat playback is currently enabled.

  • Returns: Whether repeat playback is enabled (true: repeat enabled, false: repeat disabled)

boolean com.kollus.sdk.media.MediaPlayer.isPlaying()

Checks whether playback is currently active.

  • Returns: Playback state (true: playing, false: not playing)

void com.kollus.sdk.media.MediaPlayer.pause() throws IllegalStateException

Call to pause playback.


void com.kollus.sdk.media.MediaPlayer.prepareAsync()

Starts preparing for playback asynchronously after configuring the data source (setDataSource). The onPrepared callback is received when preparation is complete.


void com.kollus.sdk.media.MediaPlayer.release()

Releases resources allocated to the player. Call after stopping playback (stop).


void com.kollus.sdk.media.MediaPlayer.seekTo(int msec) throws IllegalStateException

Moves the playback position to the specified location. (Moves in I-frame units)

  • Parameters
    • msec: Target position (ms)

void com.kollus.sdk.media.MediaPlayer.seekToExact(int msec) throws IllegalStateException

Moves the playback position to the specified location. (Moves in time units)

  • Parameters
    • msec: Target position (ms)

void com.kollus.sdk.media.MediaPlayer.selectAudio (String  language)

Selects audio for a specific language in multi-audio content.

  • Parameters
    • language: Audio to select

void com.kollus.sdk.media.MediaPlayer.selectTrack(boolean bSubTimedText, int index) throws IllegalStateException

Call to select a specific track (audio, subtitle, etc.) from the track information retrieved via getTrackInfo for playback.

  • Parameters
    • bSubTimedText: Whether it is a sub subtitle track
    • index: Index of the track to select

void com.kollus.sdk.media.MediaPlayer.setAiPlaybackRateEnable(boolean enable)

Sets whether the AI Speed feature is enabled.

  • Parameters
    • enable: Whether to enable the AI Speed feature (true: enable, false: disable)

void com.kollus.sdk.media.MediaPlayer.setAppStatus(@APP_STATUS int status)

Call to record the timing of app state changes (background/foreground) together when transmitting LMS data.

  • Parameters
    • status: App state value (APP_STATUS)

void com.kollus.sdk.media.MediaPlayer.setAudioDelay(int timeMs)

Manually adjusts the sync between video and audio.

  • Parameters
    • timeMs: Time to adjust (ms)

void com.kollus.sdk.media.MediaPlayer.setBandwidth(int bandwidth)

Forces a specific quality selection by specifying a particular bandwidth when the content uses Adaptive Bitrate(ABR).

  • Parameters
    • bandwidth: Bandwidth value to select

void com.kollus.sdk.media.MediaPlayer.setBandwidthName(String bandwidthName)

Selects quality by bandwidth name when the content uses ABR.

  • Parameters
    • bandwidthName: Bandwidth name to select

boolean com.kollus.sdk.media.MediaPlayer.setBufferingRatio(int ratio)

Sets a multiplier for the default buffering amount. Only valid when Utils.PLAYER_TYPE_KOLLUS is configured.

  • Parameters
    • ratio: Buffering multiplier to set (range: 1–10)
  • Returns: Result (true: success, false: failure)

void com.kollus.sdk.media.MediaPlayer.setCaptureDetectLister(CaptureDetectLister listener)

Sets the screen capture detection listener.

  • Parameters
    • listener: Listener instance

void com.kollus.sdk.media.MediaPlayer.setDataSourceByKey(String mediaContentKey, String extraDrmParam)

Sets the data source when playing downloaded local content.

  • Parameters
    • mediaContentKey: Content media key
    • extraDrmParam: Dynamic DRM download callback / Player Call argument

void com.kollus.sdk.media.MediaPlayer.setDataSourceByUrl(String path, String extraDrmParam)

Sets the data source (URL) for streaming playback.

  • Parameters
    • path: Path of the streaming content
    • extraDrmParam: Dynamic DRM download callback / Player Call argument

void com.kollus.sdk.media.MediaPlayer.setDisplay(SurfaceHolder sh)

Sets the screen for video output.

  • Parameters
    • sh: SurfaceHolder responsible for video output

void com.kollus.sdk.media.MediaPlayer.setEmulatorCheckerListener(EmulatorCheckerListener listener)

Sets a listener that intercepts events triggered when playback is attempted in an emulator environment.

  • Parameters
    • listener: EmulatorCheckerListener instance

void com.kollus.sdk.media.MediaPlayer.setInitialBandwidth(int bandwidth)

Sets the initial bandwidth at the start of playback. Must be called before prepareAsync().

  • Parameters
    • bandwidth: Initial viewing bandwidth
      • 0: Starts from the first item in the bandwidth list
      • Value greater than 0: Starts from the optimal bandwidth at or below that value

void com.kollus.sdk.media.MediaPlayer.setKollusPlayerBookmarkListener(KollusPlayerBookmarkListener listener)

Sets a listener to handle bookmark-related events.

  • Parameters
    • listener: KollusPlayerBookmarkListener instance

void com.kollus.sdk.media.MediaPlayer.setKollusPlayerLMSListener(KollusPlayerLMSListener listener)

Sets a listener to handle LMS data transmission-related events.

  • Parameters
    • listener: KollusPlayerLMSListener instance

void com.kollus.sdk.media.MediaPlayer.setKollusStorage(KollusStorage storage)

Sets the StorageManager instance. Execute after calling initialize() and before calling setDataSource().

  • Parameters
    • storage: KollusStorage instance

void com.kollus.sdk.media.MediaPlayer.setLastOffsetTime(int lastOffsetTimeMs)

Sets a specific viewing start position calculated backwards from the end point, based on the full timeline of MPEG-DASH content.

  • Parameters
    • lastOffsetTimeMs: Offset viewing position from the end point (ms)

void com.kollus.sdk.media.MediaPlayer.setLmsOffDownloadContent(boolean bOn)

Sets whether LMS data transmission is enabled for downloaded content.

  • Parameters
    • bOn: Whether to enable data transmission (true: enable, false: disable)

void com.kollus.sdk.media.MediaPlayer.setLooping(boolean looping)

Sets the repeat playback state for content.

  • Parameters
    • looping: Whether to enable repeat playback (true: repeat playback, false: no repeat)

void com.kollus.sdk.media.MediaPlayer.setMinDurationForQualityIncreaseMs(int msec)

Sets the minimum buffer duration that must be maintained before switching to a higher quality (bandwidth). The default value is 10 seconds and must be configured before calling prepareAsync().

  • Parameters
    • msec: Minimum buffering duration (ms)

void com.kollus.sdk.media.MediaPlayer.setMute(boolean mute)

Sets the mute state for audio output.

  • Parameters
    • mute: Whether to enable mute (true: mute enabled, false: mute disabled)

boolean com.kollus.sdk.media.MediaPlayer.setNetworkTimeout(int timeout)

Sets the network connection Timeout duration.

  • Parameters
    • timeout: Network Timeout time limit (sec)
  • Returns: Result (true: success, false: failure)

void com.kollus.sdk.media.MediaPlayer.setNotifyLastReport(boolean bOn)

Sets whether to receive a UI notification upon completion of LMS data transmission when the player exits. When enabled, the exit time may be delayed depending on the network environment.

  • Parameters
    • bOn: Whether to enable notification (true: notification enabled, false: notification disabled)

void com.kollus.sdk.media.MediaPlayer.setOnCompletionListener(OnCompletionListener listener)

Sets the OnCompletionListener.

  • Parameters
    • listener: OnCompletionListener instance

void com.kollus.sdk.media.MediaPlayer.setOnErrorListener(OnErrorListener listener)

Sets the OnErrorListener.

  • Parameters
    • listener: OnErrorListener instance

void com.kollus.sdk.media.MediaPlayer.setOnExternalDisplayDetectListener(OnExternalDisplayDetectListener listener)

Sets the OnExternalDisplayDetectListener.

  • Parameters
    • listener: OnExternalDisplayDetectListener instance

void com.kollus.sdk.media.MediaPlayer.setOnInfoListener(OnInfoListener listener)

Sets the OnInfoListener.

  • Parameters
    • listener: OnInfoListener instance

void com.kollus.sdk.media.MediaPlayer.setOnMediaRouteInfoListener(OnMediaRouteInfoListener listener)

Sets the OnMediaRouteInfoListener.

  • Parameters
    • listener: OnMediaRouteInfoListener instance

void com.kollus.sdk.media.MediaPlayer.setOnPreparedListener(OnPreparedListener listener)

Sets the OnPreparedListener.

  • Parameters
    • listener: OnPreparedListener instance

void com.kollus.sdk.media.MediaPlayer.setOnSeekCompleteListener(OnSeekCompleteListener listener)

Sets the OnSeekCompleteListener.

  • Parameters
    • listener: OnSeekCompleteListener instance

void com.kollus.sdk.media.MediaPlayer.setOnTimedTextDetectListener(OnTimedTextDetectListener listener)

Sets the OnTimedTextDetectListener.

  • Parameters
    • listener: OnTimedTextDetectListener instance

void com.kollus.sdk.media.MediaPlayer.setOnTimedTextListener(OnTimedTextListener listener)

Sets the OnTimedTextListener.

  • Parameters
    • listener: OnTimedTextListener instance

void com.kollus.sdk.media.MediaPlayer.setOnVideoSizeChangedListener(OnVideoSizeChangedListener listener)

Sets the OnVideoSizeChangedListener.

  • Parameters
    • listener: OnVideoSizeChangedListener instance

boolean com.kollus.sdk.media.MediaPlayer.setPlayingRate(float playing_rate)

Sets the playback speed. Content containing audio watermarks is limited to a maximum of 1.5x speed, and frame drops may occur above 2.0x speed.

  • Parameters
    • playing_rate: Playback speed value to set (range: 0.5–10.0)
  • Returns: Result (true: success, false: failure)

void com.kollus.sdk.media.MediaPlayer.setRemoteMediaRouteInfo(String castNameSpace)

Sets the namespace used for sending and receiving messages with a Chromecast receiver. Must be configured before calling prepareAsync().

  • Parameters
    • castNameSpace: Namespace used for communication with the Chromecast receiver. Specify MediaPlayer.CAST_NAME_SPACE when using the Kollus Cast Receiver

void com.kollus.sdk.media.MediaPlayer.setScreenOnWhilePlaying(boolean screenOn)

Sets whether to keep the screen on at all times during content playback.

  • Parameters
    • screenOn: Whether to keep the screen on (true: keep screen on at all times, false: apply automatic screen-off according to system settings)

void com.kollus.sdk.media.MediaPlayer.setSurface(Surface surface)

Sets the video output surface.

  • Parameters
    • surface: Surface instance where the video will be rendered

void com.kollus.sdk.media.MediaPlayer.setVideoRending(boolean bRendering)

Sets whether video rendering is performed.

  • Parameters
    • bRendering: Whether to perform rendering (true: render, false: do not render)

void com.kollus.sdk.media.MediaPlayer.skip()

Skips the currently playing content when an intro video is present.


void com.kollus.sdk.media.MediaPlayer.start()

Call to resume playback after pausing, or to start playback after receiving the onPrepared event.


void com.kollus.sdk.media.MediaPlayer.stop()

Stops the content currently playing.


boolean com.kollus.sdk.media.MediaPlayer.supportPlaybackrateControl()

Retrieves whether the current player supports playback speed control.

  • Returns: Whether playback speed is supported (true: supported, false: not supported)

void com.kollus.sdk.media.MediaPlayer.updateKollusBookmark(int position, String label)

Adds bookmark information at a specific point. Whether it succeeded is returned via the onBookmarkUpdated callback.

  • Parameters
    • position: Bookmark save position (ms)
    • label: Bookmark label

Property Details

static final int com.kollus.sdk.media.MediaPlayer.APP_STATUS_BACKGROUND = 1

Constant defining the background execution state of the application.


static final int com.kollus.sdk.media.MediaPlayer.APP_STATUS_FOREGROUND = 2

Constant defining the foreground execution state of the application.


static final int com.kollus.sdk.media.MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200

Error code for Progressive Download playback failure due to a structural defect in the MPEG4BOX container.


static final int com.kollus.sdk.media.MediaPlayer.MEDIA_ERROR_UNKNOWN = 1

Unidentified error code for errors whose cause cannot be determined.


static final int com.kollus.sdk.media.MediaPlayer.MEDIA_INFO_FRAME_RATE = 7

Status code for retrieving video framerate information.