Agora Java API Reference for Android
Public Member Functions | Protected Member Functions | List of all members
io.agora.rte.PlayerConfig Class Reference

This class provides methods related to Media player options. More...

Public Member Functions

long getNativeHandle ()
 
void setAutoPlay (boolean autoPlay) throws RteException
 Sets whether to enable autoplay. More...
 
boolean getAutoPlay () throws RteException
 Gets the autoplay setting. More...
 
void setPlaybackSpeed (int speed) throws RteException
 Sets the playback speed parameter. More...
 
int getPlaybackSpeed () throws RteException
 Gets the playback speed parameter. More...
 
void setPlayoutAudioTrackIdx (int idx) throws RteException
 
int getPlayoutAudioTrackIdx () throws RteException
 
void setPublishAudioTrackIdx (int idx) throws RteException
 
int getPublishAudioTrackIdx () throws RteException
 
void setAudioTrackIdx (int idx) throws RteException
 
int getAudioTrackIdx () throws RteException
 
void setSubtitleTrackIdx (int idx) throws RteException
 
int getSubtitleTrackIdx () throws RteException
 
void setExternalSubtitleTrackIdx (int idx) throws RteException
 
int getExternalSubtitleTrackIdx () throws RteException
 
void setAudioPitch (int audioPitch) throws RteException
 
int getAudioPitch () throws RteException
 
void setPlayoutVolume (int volume) throws RteException
 Sets the playback volume parameter. More...
 
int getPlayoutVolume () throws RteException
 Gets the playback volume of the media player. More...
 
void setAudioPlaybackDelay (int delay) throws RteException
 
int getAudioPlaybackDelay () throws RteException
 
void setAudioDualMonoMode (int mode) throws RteException
 
int getAudioDualMonoMode () throws RteException
 
void setPublishVolume (int volume) throws RteException
 
int getPublishVolume () throws RteException
 
void setLoopCount (int count) throws RteException
 Sets the number of times the media file loops during playback. More...
 
int getLoopCount () throws RteException
 Gets the loop count parameter of the media file. More...
 
void setJsonParameter (String jsonParameter) throws RteException
 
String getJsonParameter () throws RteException
 Gets the configured SDK JSON settings. More...
 
void setAbrSubscriptionLayer (Constants.AbrSubscriptionLayer subscriptionLayer) throws RteException
 Sets the quality level of the subscribed media stream. More...
 
Constants.AbrSubscriptionLayer getAbrSubscriptionLayer () throws RteException
 Gets the quality layer of the subscribed video stream. More...
 
void setAbrFallbackLayer (Constants.AbrFallbackLayer fallbackLayer) throws RteException
 Sets the fallback option for subscribed remote video streams. More...
 
Constants.AbrFallbackLayer getAbrFallbackLayer () throws RteException
 Gets the configured video stream fallback option. More...
 

Protected Member Functions

void finalize ()
 

Detailed Description

This class provides methods related to Media player options.

Since
v4.4.0

Member Function Documentation

◆ setAutoPlay()

void io.agora.rte.PlayerConfig.setAutoPlay ( boolean  autoPlay) throws RteException

Sets whether to enable autoplay.

Since
v4.4.0

You can call this method to set whether to enable autoplay before calling openWithUrl to open a media pull stream. If not set, autoplay is enabled by default.
Call timing: This method must be called before openWithUrl.

Parameters
autoPlayWhether to enable autoplay:
  • true: (Default) Enables autoplay.
  • false: Disables autoplay.
Exceptions
RteExceptionIf the method call fails, the SDK throws an RteException with the corresponding error information. You need to catch and handle the exception.

◆ getAutoPlay()

boolean io.agora.rte.PlayerConfig.getAutoPlay ( ) throws RteException

Gets the autoplay setting.

Since
v4.4.0

You can call this method to retrieve the current autoplay setting of the media player. Call timing: This method must be called after getConfigs(PlayerConfig config).

Returns
Whether the autoplay setting was retrieved successfully:
  • true: Retrieved successfully.
  • false: Failed to retrieve.

◆ setPlaybackSpeed()

void io.agora.rte.PlayerConfig.setPlaybackSpeed ( int  speed) throws RteException

Sets the playback speed parameter.

Since
v4.5.1

You can call this method after calling the openWithUrl method.

Parameters
speedPlayback speed. Valid range is [50, 400].

◆ getPlaybackSpeed()

int io.agora.rte.PlayerConfig.getPlaybackSpeed ( ) throws RteException

Gets the playback speed parameter.

Since
v4.5.1
Returns
If the method call succeeds, returns the value of the playback speed.

◆ setPlayoutVolume()

void io.agora.rte.PlayerConfig.setPlayoutVolume ( int  volume) throws RteException

Sets the playback volume parameter.

Since
v4.5.1

You can use this method to set the playback volume. The valid range is [0, 400].

Parameters
volumeThe volume value of the player. The valid range is [0, 400].

◆ getPlayoutVolume()

int io.agora.rte.PlayerConfig.getPlayoutVolume ( ) throws RteException

Gets the playback volume of the media player.

Since
v4.5.1
Returns
If the method call succeeds, returns the volume level of the media player.

◆ setLoopCount()

void io.agora.rte.PlayerConfig.setLoopCount ( int  count) throws RteException

Sets the number of times the media file loops during playback.

Since
v4.5.1
Parameters
countThe number of times to loop the media file:
  • 1: Play once.
  • 2: Play twice.
  • -1: Loop indefinitely until stop is called to stop playback.

◆ getLoopCount()

int io.agora.rte.PlayerConfig.getLoopCount ( ) throws RteException

Gets the loop count parameter of the media file.

Since
v4.5.1
Returns
Returns the number of times the media file loops when the method call succeeds.

◆ setJsonParameter()

void io.agora.rte.PlayerConfig.setJsonParameter ( String  jsonParameter) throws RteException

Set player private parameters. This parameter setting can be done according to actual needs, referring to the suggestions of Agora SA.

Since
v4.4.0
Parameters
jsonParameterJSON formatted string
Exceptions
RteExceptionRteException.errorCode() may return the following ErrorCode:
  • ErrorCode.INVALID_ARGUMENT: Indicates that the jsonParameter parameter is empty.
Returns
void

◆ getJsonParameter()

String io.agora.rte.PlayerConfig.getJsonParameter ( ) throws RteException

Gets the configured SDK JSON settings.

Since
v4.4.0

After you call setJsonParameter to set the JSON configuration, you can call this method to retrieve the configured settings. Call timing: This method must be called after getConfigs(Config config).

Returns
The configured JSON settings.
Exceptions
RteExceptionIf the method call fails, the SDK throws an RteException with the corresponding error information. You need to catch and handle the exception.

◆ setAbrSubscriptionLayer()

void io.agora.rte.PlayerConfig.setAbrSubscriptionLayer ( Constants.AbrSubscriptionLayer  subscriptionLayer) throws RteException

Sets the quality level of the subscribed media stream.

Since
v4.4.0

You can switch between different video quality levels of the subscribed stream based on actual network conditions, corresponding to different resolutions. By default, after calling this method, viewers can only switch between the HIGH and LOW quality levels of the video stream. If you require more advanced control over video resolution switching, you can contact technical support to enable the ABR (Adaptive Bitrate) feature. Once enabled, you can customize the resolution for each video quality level, allowing viewers to switch between all levels of the multi-layer video stream based on their needs. For detailed implementation, see the Viewer-side URL Media Pull. Applicable scenarios: In unstable network environments, the viewer can select an appropriate video quality level based on actual network conditions to ensure smooth viewing experience. Call timing: This method must be called before setConfigs(PlayerConfig config).

Note
If the ABR feature is not enabled, you can only subscribe to the HIGH or LOW video quality levels.
Parameters
subscriptionLayerThe video quality level to subscribe to. See AbrSubscriptionLayer. When customizing resolutions for LAYER1 to LAYER6, you can refer to the table below, or configure them based on your actual requirements: Note: When customizing resolutions, be sure to sort the video quality levels (Layers) in descending order of resolution, and by descending frame rate if resolutions are the same.
Video Quality Layer Resolution
LAYER1 2160p (4K)
LAYER2 1440p (2K)
LAYER3 1080p (HD)
LAYER4 720p (HD)
LAYER5 540p (SD)
LAYER6 480p (SD)
Exceptions
RteExceptionIf the method call fails, the SDK throws an RteException with corresponding error information. You need to catch and handle the exception.

◆ getAbrSubscriptionLayer()

Constants.AbrSubscriptionLayer io.agora.rte.PlayerConfig.getAbrSubscriptionLayer ( ) throws RteException

Gets the quality layer of the subscribed video stream.

Since
v4.4.0

Call timing: You need to call this method after getConfigs(PlayerConfig config).

Returns
The currently set video quality layer. See AbrSubscriptionLayer for details.
Exceptions
RteExceptionIf the method call fails, the SDK throws an RteException with the corresponding error information. You need to catch and handle the exception.

◆ setAbrFallbackLayer()

void io.agora.rte.PlayerConfig.setAbrFallbackLayer ( Constants.AbrFallbackLayer  fallbackLayer) throws RteException

Sets the fallback option for subscribed remote video streams.

Since
v4.4.0

In suboptimal network conditions, the quality of real-time audio and video communication may degrade. After calling this method, the SDK downgrades the resolution of the video stream to the specified quality layer when network conditions worsen. Each video quality layer corresponds to a specific resolution and bitrate. At the same time, the SDK continuously monitors network conditions and restores the subscribed remote video streams to the original quality layer when the network improves. By default, after calling this method, you can only choose to fall back to LOW or AUDIO_ONLY. If you require higher video quality, you can contact technical support to enable the ABR feature. Once enabled, you can fall back to any quality layer of the multi-layer video stream and customize the resolution corresponding to each layer. Applicable scenarios:

  • In general video scenarios, you can call this method and set the fallback quality layer to LOW or AUDIO_ONLY. The SDK downgrades the video stream to a lower-quality stream or receives only the audio stream when the network is poor.
  • If you have higher requirements for the resolution of fallback video streams, you can contact technical support to enable the ABR feature. Once enabled, you can customize the resolution of each layer. The SDK dynamically adjusts the resolution within the range starting from the lowest resolution layer you specify, depending on the network conditions. For implementation details, refer to Audience-side URL streaming. Call timing: You must call this method before setConfigs(PlayerConfig config).
Note
If you have not enabled the ABR feature when calling this method, the fallback quality layer of the video stream can only be set to LOW or AUDIO_ONLY.
Parameters
fallbackLayerThe fallback quality layer for the video stream. See AbrFallbackLayer. When customizing the resolution for LAYER1 through LAYER6, you can refer to the table below or define them based on your actual needs:
Video Quality Layer Resolution
LAYER1 2160p (4K)
LAYER2 1440p (2K)
LAYER3 1080p (HD)
LAYER4 720p (HD)
LAYER5 540p (SD)
LAYER6 480p (SD)
Note: When customizing resolutions, make sure to sort the video quality layers from highest to lowest resolution. If the resolutions are the same, sort them by frame rate in descending order.
Exceptions
RteExceptionIf this method call fails, the SDK throws an RteException with the corresponding error information. You need to catch and handle the exception accordingly.

◆ getAbrFallbackLayer()

Constants.AbrFallbackLayer io.agora.rte.PlayerConfig.getAbrFallbackLayer ( ) throws RteException

Gets the configured video stream fallback option.

Since
v4.4.0

Call timing: You must call this method after getConfigs(PlayerConfig config).

Returns
The configured video stream fallback option. See AbrFallbackLayer for details.
Exceptions
RteExceptionIf the method call fails, the SDK throws an RteException with the corresponding error information. You need to catch and handle the exception.