API | Description |
Play an HTTP URL-formatted address. Starting from version 10.7, `startPlay` has been changed to `startVodPlay`. You need to call `TXLiveBase#setLicence` to set the License before successful playback; otherwise, playback will fail (resulting in a black screen). The License only needs to be set globally once. Live stream License, short video License, and player License can all be used. If you have not obtained the above License yet, you can click Player License to apply. An official License requires purchase. | |
Play in fileId format, pass in TXPlayInfoParams parameter. Starting from version 10.7, startPlay is changed to startVodPlay. You must call {@link TXLiveBase#setLicence} to set the Licence before successful playback; otherwise, playback will fail (black screen). The Licence only needs to be set globally once. Live stream Licence, short video Licence, and player Licence can all be used. If you have not obtained the above Licence yet, you can click Player License to apply. The official license requires purchase. | |
Play DRM-encrypted video. | |
Stop playback. | |
Whether it is playing. | |
Pause playback Stop retrieving streaming data Retain the last frame | |
Resume playback. Re-fetch streaming data. | |
Navigate to the specified time point in the video stream, in seconds. | |
Navigate to the specified time point in the video stream, in seconds, with precision up to 3 decimal places. | |
Retrieve the current playback position, in seconds. | |
Retrieve the total duration of the cache, in seconds. | |
Retrieve the total duration, in seconds. | |
Retrieve the playable duration, in seconds. | |
Get video width. | |
Retrieve video height. | |
Set whether to autoplay after startPlay, default is autoplay. | |
Set playback start time. | |
Encrypt the token for HLS. | |
Retrieve the encryption key for secure encrypted playback. | |
Set whether to loop playback. | |
Return whether the playback loop status is enabled. | |
Add external subtitle (only supported in player premium). | |
Return subtitle track information list (only supported in player premium). | |
Return audio track information list (only supported in player premium). | |
Select track (only supported in player premium). | |
Cancel track selection (only supported in player premium). | |
Navigate to a specified PDT (Program Date Time) time point in the video stream, enabling features such as fast-forward, rewind, and progress bar jumping. Currently only supports HLS video format (starting from player premium version 11.6). Parameter unit: milliseconds (ms). |
API | Description |
Set the video rendering TXCloudVideoView for the player. | |
Set the video rendering TextureView for the player. | |
Set the video rendering Surface for the player. | |
Set the player's business parameters, with the parameter format as <String,Object>. | |
Set subtitle style information. Subtitle styles can be updated after playback (only supported in player premium). | |
Set the subtitle rendering target object View (only supported in player premium). | |
Set volume equalization and loudness range. Default values can be filled in (related classes or files: Android: TXVodConstants; iOS: TXVodPlayConfig.h). {Turn off: AUDIO_NORMALIZATION_OFF} {On: AUDIO_NORMALIZATION_ON} AUDIO_NORMALIZATION_STANDARD AUDIO_NORMALIZATION_LOW AUDIO_NORMALIZATION_HIGH Custom value can be filled in: ranging from -70 to 0 LUFS. |
API | Description |
Enable or disable video hardware decoding. | |
Retrieve the current video frame. Note: Since retrieving the current frame image is a time-consuming operation, the screenshot will be returned via an asynchronous callback. | |
Set the image. | |
Set the playback speed of on-demand video, default is 1.0. | |
Return the bitrate index of current playback. | |
When the playback address is HLS, return the list of supported bitrates (resolutions). | |
Set the bitrate index of the currently playing content. Switch resolution seamlessly. Clarity switching may require a short while. | |
Set the switchable highest bitrate for adaptive playback. |
API | Description |
Set whether to mute playback. | |
Set volume level, range: 0 - 100. | |
Set whether to automatically obtain audio focus. Default is automatic obtain. |
API | Description |
Set video subtitle text data output callback. | |
Set player event callback. |
API | Description |
Bind VOD to TRTC service. | |
Unbind VOD from TRTC service. | |
Start pushing video stream. | |
Cancel pushing video stream. | |
Start pushing audio stream. | |
Cancel pushing audio stream. |
public TXVodPlayer(Context context)
Parameter Name | Type | Description |
context | Context | System |
public int startVodPlay(String playUrl)
Parameter Name | Type | Description |
playUrl | String | Playback address. |
public void startVodPlay(TXPlayInfoParams playInfoParams)
Parameter Name | Type | Description |
playInfoParams | TXPlayInfoParams | System |
public int startPlayDrm(TXPlayerDrmBuilder playerDrmBuilder)
Parameter Name | Type | Description |
playerDrmBuilder | TXPlayerDrmBuilder | Playback information for Drm. |
public int stopPlay(boolean isNeedClearLastImg)
Parameter Name | Type | Description |
isNeedClearLastImg | boolean | Whether to clear the last frame. true: Clear the last frame. It is recommended to clear when stopping playback normally. false: Retain the last frame. |
public boolean isPlaying()
public void pause()
public void resume()
public void seek(int time)
Parameter Name | Type | Description |
time | int | Video stream time point, in seconds. |
public void seek(float time)
Parameter Name | Type | Description |
time | float | Video stream time point, in seconds, with precision up to 3 decimal places. |
public void seek(float timeInSeconds, boolean isAccurateSeek)
Parameter Name | Type | Description |
timeInSeconds | float | Video stream time point, in seconds, with precision up to 3 decimal places. |
isAccurateSeek | boolean | Whether it is precise Seek. true: Indicates precise Seek, must find the current time point, which may take longer. false: Indicates imprecise Seek, that is, searching for the previous I-frame. |
public void seekToPdtTime(long pdtTimeMs)
Parameter Name | Type | Description |
pdtTimeMs | long | Video stream PDT time point, in milliseconds. |
public float getCurrentPlaybackTime()
public float getBufferDuration()
public float getDuration()
public float getPlayableDuration()
public int getWidth()
public int getHeight()
public void setAutoPlay(boolean autoPlay)
public void setStartTime(float pos)
Parameter Name | Type | Description |
pos | float | Video stream time point, in seconds, with precision up to 3 decimal places. |
public void setToken(String token)
public static String getEncryptedPlayKey(final String key)
public void setLoop(boolean loop)
public void setLoop(boolean loop)
public void addSubtitleSource(@NonNull String url, @NonNull String name, String mimeType)
Parameter Name | Type | Description |
url | String | Subtitle address, supports Http link and local storage absolute path. |
name | String | Subtitle name. If adding multiple subtitles, set the subtitle names to different names to distinguish them from other added subtitles; otherwise, it may result in subtitle selection error. |
mimeType | String | Subtitle type, only supports VVT and SRT format. VTT format: TXVodConstants#VOD_PLAY_MIMETYPE_TEXT_SRT SRT format: TXVodConstants#VOD_PLAY_MIMETYPE_TEXT_VTT |
public List<TXTrackInfo> getSubtitleTrackInfo()
public List<TXTrackInfo> getAudioTrackInfo()
public void selectTrack(int trackIndex)
Parameter Name | Type | Description |
trackIndex | int | Track index, obtained via TXTrackInfo#getTrackIndex. |
public void deselectTrack(int trackIndex)
Parameter Name | Type | Description |
trackIndex | int | Track index, obtained via TXTrackInfo#getTrackIndex. |
public void setConfig(TXVodPlayConfig config)
public void setPlayerView(TXCloudVideoView glRootView)
Parameter Name | Type | Description |
glRootView | TXCloudVideoView | video rendering View. |
public void setPlayerView(TextureRenderView glRootView)
Parameter Name | Type | Description |
glRootView | TextureRenderView | video rendering View. |
public void setSurface(Surface surface)
<String,Object>.public void setStringOption(String key, Object value)
public void setSubtitleStyle(TXSubtitleRenderModel renderModel)
Parameter Name | Type | Description |
renderModel | Subtitle style configuration parameters. |
public void setSubtitleView(TXSubtitleView subtitleView)
Parameter Name | Type | Description |
subtitleView | TXSubtitleView | The subtitle rendering target object View provided by player SDK. |
public void setAudioNormalization(float value)
Parameter Name | Type | Description |
value | float | Preset value can be filled in (related class or file: Android: TXVodConstants; iOS: TXVodPlayConfig.h) Turn off: AUDIO_NORMALIZATION_OFF On: AUDIO_NORMALIZATION_ON AUDIO_NORMALIZATION_STANDARD AUDIO_NORMALIZATION_LOW AUDIO_NORMALIZATION_HIGH Custom value can be filled in: ranging from -70 to 0 LUFS. |
public void setAutoMaxBitrate(int autoMaxBitrate)
public boolean enableHardwareDecode(boolean enable)
public void snapshot(TXLivePlayer.ITXSnapshotListener listener)
Parameter Name | Type | Description |
listener | public interface ITXSnapshotListener { void onSnapshot(Bitmap bmp); } | Callback interface class for screenshots. |
public void setMirror(boolean mirror)
public void setRate(float rate)
public TXVodPlayer(Context context)
public ArrayList<TXBitrateItem> getSupportedBitrates
public void setBitrateIndex(int index) {
Parameter Name | Type | Description |
index | int | Bitrate index. index == -1 indicates enabling HLS adaptive bitrate streaming. index > 0 means manually switching to the corresponding clarity bitrate. The index value can be obtained through the API TXVodPlayer#getSupportedBitrates. |
public void setRenderMode(int mode)
Parameter Name | Type | Description |
mode | int | Image Tiling Mode, valid values: TXVodConstants#RENDER_MODE_FULL_FILL_SCREEN: Fill the video footage to the entire screen, scale the image proportionally to cover the whole screen, and crop the excess part. In this mode, there is no black border on the screen. TXVodConstants#RENDER_MODE_ADJUST_RESOLUTION: Adapt the video footage to the screen, scale the image proportionally, ensure the scaled width and height do not exceed the display area, display it centered, and may leave a black border. |
public void setRenderRotation(int rotation)
Parameter Name | Type | Description |
context | Context | Image rendering angle, valid values: TXVodConstants#RENDER_ROTATION_PORTRAIT: portrait TXVodConstants#RENDER_ROTATION_LANDSCAPE: Rotate 90 degrees clockwise. |
public void setMute(boolean mute)
public void setAudioPlayoutVolume(int volume)
public boolean setRequestAudioFocus(boolean requestFocus)
public void setVodSubtitleDataListener(ITXVodPlayListener.ITXVodSubtitleDataListener listener)
Parameter Name | Type | Description |
listener | Subtitle text data callback API. |
public void setVodListener(ITXVodPlayListener listener)
Parameter Name | Type | Description |
listener | Player event callback API. |
public void attachTRTC(Object trtcCloud)
public void detachTRTC()
public void publishVideo()
public void unpublishVideo()
public void publishAudio()
public void unpublishAudio()
Feedback