LiteAVSDK
Tencent Cloud TRTC SDK, is a high availability components serving tens of thousands of enterprise customers, which is committed to helping you to minimize your research and development costs.
TXVodPlayer

Data Structures

interface  TXVodPlayer.ITXSnapshotListener
 
class  TXVodPlayer
 

Detailed Description

The VOD player API class
The player has the following capabilities:


Data Structure Documentation

◆ com::tencent::rtmp::TXVodPlayer::ITXSnapshotListener

interface com::tencent::rtmp::TXVodPlayer::ITXSnapshotListener

The screenshot callback, which is used to receive the current video image.

Public Member Functions

void onSnapshot (Bitmap bmp)
 

Member Function Documentation

◆ onSnapshot()

void onSnapshot ( Bitmap  bmp)

Callback for a screenshot taken

Parameters
bmpThe current video image

◆ com::tencent::rtmp::TXVodPlayer

class com::tencent::rtmp::TXVodPlayer

Public Member Functions

 TXVodPlayer (Context context)
 
void setConfig (TXVodPlayConfig config)
 
void setPlayerView (TXCloudVideoView glRootView)
 
void setPlayerView (TextureRenderView glRootView)
 
void setSubtitleView (TXSubtitleView subtitleView)
 
void addSubtitleSource (@NonNull String url, @NonNull String name, String mimeType)
 
void selectTrack (int trackIndex)
 
void deselectTrack (int trackIndex)
 
List< TXTrackInfogetSubtitleTrackInfo ()
 
List< TXTrackInfogetAudioTrackInfo ()
 
void setSubtitleStyle (TXSubtitleRenderModel renderModel)
 
void setSurface (Surface surface)
 
int startVodPlay (String playUrl)
 
int startVodPlay (TXPlayerAuthBuilder authBuilder)
 
void startVodPlay (TXPlayInfoParams playInfoParams)
 
int startPlayDrm (TXPlayerDrmBuilder playerDrmBuilder)
 
int stopPlay (boolean isNeedClearLastImg)
 
boolean isPlaying ()
 
void pause ()
 
void resume ()
 
void seek (int time)
 
void seek (float time)
 
float getCurrentPlaybackTime ()
 
float getBufferDuration ()
 
float getDuration ()
 
float getPlayableDuration ()
 
int getWidth ()
 
int getHeight ()
 
void setPlayListener (ITXLivePlayListener listener)
 
void setVodListener (ITXVodPlayListener listener)
 
void setRenderMode (int mode)
 
void setRenderRotation (int rotation)
 
boolean enableHardwareDecode (boolean enable)
 
void setMute (boolean mute)
 
void setAudioPlayoutVolume (int volume)
 
boolean setRequestAudioFocus (boolean requestFocus)
 
void setAutoPlay (boolean autoPlay)
 
void setRate (float rate)
 
int getBitrateIndex ()
 
void setBitrateIndex (int index)
 
ArrayList< TXBitrateItemgetSupportedBitrates ()
 
void snapshot (TXLivePlayer.ITXSnapshotListener listener)
 
void setMirror (boolean mirror)
 
void setStartTime (float pos)
 
void setToken (String token)
 
void setLoop (boolean loop)
 
boolean isLoop ()
 
void attachTRTC (Object trtcCloud)
 
void detachTRTC ()
 
void publishVideo ()
 
void unpublishVideo ()
 
void publishAudio ()
 
void unpublishAudio ()
 
void setStringOption (String key, Object value)
 

Static Public Member Functions

static String getEncryptedPlayKey (final String key)
 

Constructor & Destructor Documentation

◆ TXVodPlayer()

TXVodPlayer ( Context  context)
inline

Construct a TXVodPlayer object

Parameters
contextThe application context

Member Function Documentation

◆ addSubtitleSource()

void addSubtitleSource ( @NonNull String  url,
@NonNull String  name,
String  mimeType 
)
inline

Add external subtitles

Parameters
urlSubtitle address
nameThe name of the subtitle. If you add multiple subtitles, please set the subtitle name to a different name to distinguish it from other added subtitles, otherwise it may cause wrong subtitle selection.
mimeTypeSubtitle type, only supports VVT and SRT formats TXVodConstants#VOD_PLAY_MIMETYPE_TEXT_SRT, TXVodConstants#VOD_PLAY_MIMETYPE_TEXT_VTT. Later, you can get the corresponding name through TXTrackInfo#getName() in getSubtitleTrackInfo().

◆ attachTRTC()

void attachTRTC ( Object  trtcCloud)
inline

This API is used to push the substream. After attachment, audio playback will be performed by TRTC.

Parameters
trtcCloudThe TRTC instance pointer

◆ deselectTrack()

void deselectTrack ( int  trackIndex)
inline

Deselect track

Parameters
trackIndextrack index, obtained through TXTrackInfo#getTrackIndex()

◆ detachTRTC()

void detachTRTC ( )
inline

This API is used to detach the current vodPlayer from TRTC.

◆ enableHardwareDecode()

boolean enableHardwareDecode ( boolean  enable)
inline

This API is used to set whether to enable hardware acceleration.

Parameters
enable
Returns

◆ getAudioTrackInfo()

List<TXTrackInfo> getAudioTrackInfo ( )
inline

Return the list of audio track information

Returns
Audio track information list

◆ getBitrateIndex()

int getBitrateIndex ( )
inline

This API is used to get the bitrate index of the video being played back.

Returns
The bitrate index of the video being played back

◆ getBufferDuration()

float getBufferDuration ( )
inline

This API is used to get the buffered duration.

Returns
A value in seconds

◆ getCurrentPlaybackTime()

float getCurrentPlaybackTime ( )
inline

This API is used to get the current playback time.

Returns
A value in seconds

◆ getDuration()

float getDuration ( )
inline

This API is used to get the total video duration.

Returns
A value in seconds

◆ getEncryptedPlayKey()

static String getEncryptedPlayKey ( final String  key)
inlinestatic

This API is used to get the encrypted playback key.

Parameters
keyencrypted playback key.

◆ getHeight()

int getHeight ( )
inline

The video height.

Returns
he height of the video

◆ getPlayableDuration()

float getPlayableDuration ( )
inline

The playable duration.

Returns
A value in seconds

◆ getSubtitleTrackInfo()

List<TXTrackInfo> getSubtitleTrackInfo ( )
inline

Return subtitle track information list

Returns
Subtitle track information list

◆ getSupportedBitrates()

ArrayList<TXBitrateItem> getSupportedBitrates ( )
inline

This API is used to return the supported bitrates (definitions) if the playback address is a master playlist.

Returns
The bitrate list. An empty array can be returned if multi-bitrate is not configured.

◆ getWidth()

int getWidth ( )
inline

The video width.

Returns
The width of the video

◆ isLoop()

boolean isLoop ( )
inline

Checks whether the player is looping or non-looping.

Returns
true if the player is currently looping, false otherwise

◆ isPlaying()

boolean isPlaying ( )
inline

This API is used to check whether the playback is ongoing.

Returns
Whether the playback is ongoing. Valid values: true: yes; false: no.

◆ pause()

void pause ( )
inline

Pauses playback

◆ publishAudio()

void publishAudio ( )
inline

This API is used to start pushing the audio substream to TRTC.

◆ publishVideo()

void publishVideo ( )
inline

This API is used to start pushing the video substream to TRTC.

◆ resume()

void resume ( )
inline

This API is used to resume playback.

◆ seek() [1/2]

void seek ( float  time)
inline

This API is used to seek the video stream to the specified time point.

This API can be used to implement features such as fast forward, fast rewind, and progress bar seek.

Parameters
timeThe video stream time point in seconds, accurate down to three decimal places.

◆ seek() [2/2]

void seek ( int  time)
inline

This API is used to seek the audio/video stream to the specified time point. This API can be used to implement features such as fast forward, fast rewind, and progress bar seek.

Parameters
timeThe video stream time point in seconds

◆ selectTrack()

void selectTrack ( int  trackIndex)
inline

Select track

Parameters
trackIndexTrack index, obtained through TXTrackInfo#getTrackIndex()

◆ setAudioPlayoutVolume()

void setAudioPlayoutVolume ( int  volume)
inline

This API is used to set the volume level.

Parameters
volumeVolume. Value range: 0-150; default: 100

◆ setAutoPlay()

void setAutoPlay ( boolean  autoPlay)
inline

This API is used to set whether to start VOD automatically after call of startPlay. VOD starts automatically by default.

Parameters
autoPlay

◆ setBitrateIndex()

void setBitrateIndex ( int  index)
inline

This API is used to set the bitrate index of the video being played back for seamless definition switch. You may need to wait momentarily to switch the definition. Tencent Cloud supports multi-bitrate segment alignment to guarantee an optimal viewing experience.

Parameters
indexThe bitrate index. index == -1 indicates to enable adaptive bitrate streaming for HLS files. index > 0 TXVodPlayer#getSupportedBitrates()` indicates to manually switch to the target bitrate (definition).
See also
TXBitrateItem#index

◆ setConfig()

void setConfig ( TXVodPlayConfig  config)
inline

This API is used to set the player configuration information. We recommend you set the configuration information before starting the playback.

Parameters
configThe player configuration information. For more information, see TXVodPlayConfig.

◆ setLoop()

void setLoop ( boolean  loop)
inline

This API is used to set whether to loop the playback.

Parameters
loop

◆ setMirror()

void setMirror ( boolean  mirror)
inline

This API is used to set whether the video image is mirrored.

Parameters
mirror

◆ setMute()

void setMute ( boolean  mute)
inline

This API is used to set muting.

Parameters
muteWhether to mute the player. Valid values: true: yes; false: no.

◆ setPlayerView() [1/2]

void setPlayerView ( TextureRenderView  glRootView)
inline

This API is used to set TextureRenderView for video rendering in the player. We recommend you use TXCloudVideoView instead.

Parameters
glRootViewThe TextureRenderView for video rendering

◆ setPlayerView() [2/2]

void setPlayerView ( TXCloudVideoView  glRootView)
inline

This API is used to set TXCloudVideoView for video rendering in the player This feature can take effect only if it is set before playback starts

Parameters
glRootViewThe TXCloudVideoView for video rendering

◆ setPlayListener()

void setPlayListener ( ITXLivePlayListener  listener)
inline

This API is used to set the player callback. We recommend you use the setVodListener API. For more information, see class ITXVodPlayListener.

Parameters
listenerThe player callback. For more information, see class ITXLivePlayListener.
Deprecated:
This API has been deprecated. We recommend you use setVodListener

◆ setRate()

void setRate ( float  rate)
inline

This API is used to set the playback speed.

Parameters
rateThe playback speed. Value range: 0.5–2.0.

◆ setRenderMode()

void setRenderMode ( int  mode)
inline

Used for the window rendering mode

Parameters
modeThe image fill mode. For more information, see image fill mode.

◆ setRenderRotation()

void setRenderRotation ( int  rotation)
inline

Set the clockwise rotation angle of the local image

Parameters
rotationThe image rendering angle. For more information, see image rendering angle.

◆ setRequestAudioFocus()

boolean setRequestAudioFocus ( boolean  requestFocus)
inline

This API is used to set whether to get the audio focus automatically, which is yes by default.

Parameters
requestFocus
Returns
true: Setting succeeded; false: Setting failed. This feature can take effect only if it is set before playback starts.

◆ setStartTime()

void setStartTime ( float  pos)
inline

This API is used to set the playback start time.

Parameters
startTimeThe video stream time point in seconds, accurate down to three decimal places.

◆ setStringOption()

void setStringOption ( String  key,
Object  value 
)
inline

This API is used to set extended option parameters.

Parameters
key
value

◆ setSubtitleStyle()

void setSubtitleStyle ( TXSubtitleRenderModel  renderModel)
inline

Configure subtitle style

Parameters
renderModelSupport style reference TXSubtitleRenderModel

◆ setSubtitleView()

void setSubtitleView ( TXSubtitleView  subtitleView)
inline

Set subtitle rendering target.

Parameters
subtitleViewTXSubtitleView

◆ setSurface()

void setSurface ( Surface  surface)
inline

This API is used to set the surface and supports only hardware decoding currently.

The player can run normally only if the surface is valid. When using this API for playback, you need to call resume() or pause() manually.

Parameters
surfaceThe video rendering surface

◆ setToken()

void setToken ( String  token)
inline

The token for HLS encryption. After the token is set, the player will automatically add voddrm.token.TOKEN before the filename in the URL.

Parameters
token

◆ setVodListener()

void setVodListener ( ITXVodPlayListener  listener)
inline

This API is used to set the player callback.

Parameters
listenerThe player callback. For more information, see class ITXVodPlayListener

◆ snapshot()

void snapshot ( TXLivePlayer.ITXSnapshotListener  listener)
inline

This API gets the current video frame image. Note: As this operation is time-consuming, the screenshot will be called back asynchronously.

Parameters
listener

◆ startPlayDrm()

int startPlayDrm ( TXPlayerDrmBuilder  playerDrmBuilder)
inline

This API is used to start playing back a file encrypted with standard FairPlay DRM.

Parameters
playerDrmBuilderThe DRM playback information. For more information, see TXPlayerDrmBuilder.
Returns
Whether playback started successfully. Valid values: 0: yes; -1: no.

◆ startVodPlay() [1/3]

int startVodPlay ( String  playUrl)
inline

This API is used to start playback.

Attention
Starting from version 10.7, the Licence needs to be set through TXLiveBase#setLicence before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be purchased.
Parameters
urlThe URL of the stream to be played back
Returns
Whether playback started successfully. Valid values: 0: yes; -1: no.

◆ startVodPlay() [2/3]

int startVodPlay ( TXPlayerAuthBuilder  authBuilder)
inline

This API is used to start playback through fileId. This API has been deprecated. We recommend you use this#startPlay(TXPlayInfoParams).

Attention
Starting from version 10.7, the Licence needs to be set through TXLiveBase#setLicence before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be purchased.
Parameters
authBuilder
Returns
Whether playback started successfully

◆ startVodPlay() [3/3]

void startVodPlay ( TXPlayInfoParams  playInfoParams)
inline

This API is used to start playback through fileId.

Attention
Starting from version 10.7, the Licence needs to be set through TXLiveBase#setLicence before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be purchased.
Parameters
playInfoParamsParameters for playback through fileId. For more information, see TXPlayInfoParams.

◆ stopPlay()

int stopPlay ( boolean  isNeedClearLastImg)
inline

This API is used to stop playing audio/video streams.

Parameters
isNeedClearLastImgWhether to clear the last image frame on Android. Valid values: true: yes; false: no. We recommend you set this value to true when playback ends normally. If playback stops due to an exception (for example, a network exception occurs and forces the playback to stop), but you want playback to resume when the SDK is reconnected to the server, set this value to false.
Returns
Whether playback stopped successfully. Valid values: 0: yes; other values: no.

◆ unpublishAudio()

void unpublishAudio ( )
inline

This API is used to stop pushing the audio substream to TRTC.

◆ unpublishVideo()

void unpublishVideo ( )
inline

This API is used to stop pushing the video substream to TRTC.