tencent cloud

TXVodPlayConfig
Last updated: 2025-05-30 15:02:13
TXVodPlayConfig
Last updated: 2025-05-30 15:02:13

TXVodPlayConfig API Introduction

on-demand player playback configuration, need to be set before playback.

API Overview

API
Description
Set the player's reconnection attempts in abnormal scenarios.
Set the player connection timeout period.
Set the player type.
Set the Http header.
Set whether to seek accurately.
Set whether to automatically rotate the angle when playing MP4.
Set whether to smoothly switch between multiple bitrates for HLS.
Set the cache for MP4 filename extension.
Set interval for progress callbacks.
Set the maximum playback buffer size for the player.
Set the maximum preload buffer size.
Set whether the player is allowed to load post-processing services.
Set the optimal HLS stream for startup playback.
Set MP4 encrypted playback.
Set the media asset type for player playback.
Set the player's expanded parameters.
Set the preferred audio track for startup playback.

API Detail

setConnectRetryCount

Set the player's reconnection attempts in abnormal scenarios.
When the SDK is disconnected due to an exception from the server, it will attempt to reconnect to the server. Use this function to set the reconnection attempts of the SDK, with a default value of 3.
public void setConnectRetryCount(int count)
Parameter Description
Parameter Name
Type
Description
count
int
Reconnection attempts in playback exception scenarios.

setTimeout

Set the player connection timeout period, with a default value of 10 seconds.
public void setTimeout(int timeout)
Parameter Description
Parameter Name
Type
Description
interval
int
Connection timeout, in seconds, default value is 10 seconds.

setCacheFolderPath

Set the video-on-demand cache directory.
Note: This API is deprecated. Please use TXPlayerGlobalSetting#setCacheFolderPath for global configuration.
public void setCacheFolderPath(String folderPath)
Parameter Description
Parameter Name
Type
Description
folderPath
String
cache path.

setMaxCacheItems

Set the number of cached files.
Note: This API is deprecated. Please use TXPlayerGlobalSetting#setMaxCacheSize for global configuration.
public void setMaxCacheItems(int maxCacheItems)
Parameter Description
Parameter Name
Type
Description
maxCacheItems
int
Maximum cache entries.

setPlayerType

Set player type, default is Tencent Cloud proprietary player.
public void setPlayerType(int playerType)
Parameter Description
Parameter Name
Type
Description
playerType
int
Player type, valid values:
TXVodConstants#PLAYER_SYSTEM_MEDIA_PLAYER: Android system player.
TXVodConstants#PLAYER_THUMB_PLAYER: Tencent Cloud proprietary player, default value.

setHeaders

Customize configuration for the player to play with Http headers carried during the online process.
public void setHeaders(Map<String, String> headers)
Parameter Description
Parameter Name
Type
Description
headers
Map<String, String>
Custom Http header content.

setEnableAccurateSeek

Set whether to seek accurately. Default true.
public void setEnableAccurateSeek(boolean accurateSeek)
Parameter Description
Parameter Name
Type
Description
accurateSeek
boolean
Set whether to seek accurately.

setAutoRotate

When playing an MP4 file, if set to YES, it will automatically rotate according to the rotation angle in the file. The rotation angle can be obtained in the PLAY_EVT_CHANGE_ROTATION event, with a default value of YES.
public void setAutoRotate(boolean autoRotate)
Parameter Description
Parameter Name
Type
Description
autoRotate
boolean
Set whether to automatically rotate the angle during playback.

setSmoothSwitchBitrate

Set whether to smoothly switch between multiple bitrates for HLS, default false.
public void setSmoothSwitchBitrate(boolean smoothSwitchBitrate)
Parameter Description
Parameter Name
Type
Description
smoothSwitchBitrate
boolean
Whether to smoothly switch between multiple bitrates for HLS.

setCacheMp4ExtName

Set the cache for mp4 filename extension. The default is mp4.
public void setCacheMp4ExtName(String cacheMp4ExtName)
Parameter Description
Parameter Name
Type
Description
cacheMp4ExtName
boolean
Filename extension.

setProgressInterval

Set the interval for progress callbacks, with a default value of 0.5 seconds per callback.
public void setProgressInterval(int intervalMs)
Parameter Description
Parameter Name
Type
Description
intervalMs
int
Interval time, in milliseconds.

setMaxBufferSize

Set the maximum playback buffer size, in MB.
public void setMaxBufferSize(float maxBufferSize)
Parameter Description
Parameter Name
Type
Description
maxBufferSize
float
Playback buffer size

setMaxPreloadSize

Set the maximum preload buffer size, in MB.
public void setMaxPreloadSize(float maxPreloadSize)
Parameter Description
Parameter Name
Type
Description
maxPreloadSize
float
Preload size.

setFirstStartPlayBufferTime

Set the data duration for the player's initial preload, in ms, with a default value of 100ms.
Note: This API is deprecated. Please use #setMaxBufferSize or #setMaxPreloadSize to set the buffer size.
public void setFirstStartPlayBufferTime(int milliseconds)
Parameter Description
Parameter Name
Type
Description
milliseconds
int
Duration size.

setEnableRenderProcess

Set whether the player is allowed to load post-processing services, off by default.
public void setEnableRenderProcess(boolean enableRenderProcess)
Parameter Description
Parameter Name
Type
Description
enableRenderProcess
boolean
Set whether loading post-rendering post-processing services is allowed.

setPreferredResolution

When playing HLS with multiple streams, the player selects the optimal stream for startup playback based on the set preferredResolution, which is the product of width and height (width * height).
Settings are only valid before playback starts.
public void setPreferredResolution(long preferredResolution)
Parameter Description
Parameter Name
Type
Description
preferredResolution
long
Product of video width and height (width * height).

setEncryptedMp4Level

Set MP4 encrypted playback, not encrypted (default).
public void setEncryptedMp4Level(int level)
Parameter Description
Parameter Name
Type
Description
level
int
Set MP4 playback and storage encryption levels, supported starting from Player Premium 12.2, currently supports:
TXVodConstants#MP4_ENCRYPTION_LEVEL_NONE: Unencrypted playback, supported by default.
TXVodConstants#MP4_ENCRYPTION_LEVEL_L2: MP4 local encrypted playback.

setMediaType

Set the media asset type for player playback, default is AUTO type.
public void setMediaType(int mediaType)
Parameter Description
Parameter Name
Type
Description
mediaType
int
Set the media asset type, default is AUTO type. Optional values:
TXVodConstants#MEDIA_TYPE_AUTO, AUTO type (default value, adaptive bit rate playback not supported).
TXVodConstants#MEDIA_TYPE_HLS_VOD, HLS VOD media.
TXVodConstants#MEDIA_TYPE_HLS_LIVE, HLS live media.
TXVodConstants#MEDIA_TYPE_FILE_VOD, common file VOD media such as MP4 (supported starting from version 11.2).
TXVodConstants#MEDIA_TYPE_DASH_VOD, DASH VOD media (supported starting from version 11.2)

setExtInfo

Set the player's expanded parameters.
public void setExtInfo(Map<String, Object> map)
Parameter Description
Parameter Name
Type
Description
map
Map
Expanded parameters

setPreferredAudioTrack

Set the preferred audio track for startup playback, supported starting from Player Premium version 12.3.
public void setPreferredAudioTrack(String audioTrackName)
Parameter Description
Parameter Name
Type
Description
audioTrackName
String
audio track name.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback