tencent cloud

Feedback

API Documentation

Last updated: 2023-03-15 17:43:58

    TXVodPlayer

    VOD player

    See TXVodPlayer. The player pulls audio/video data from the specified VOD stream URL and plays the data after decoding and local rendering. The player has the following capabilities:
    FLV, MP4, and HLS files can be played back in two playback methods: basic playback (by URL) and VOD playback (by Fileid ).
    Screenshots of the video stream can be taken.
    The brightness, volume level, and playback progress can be adjusted through gestures.
    Resolution can be switched manually or resolution can be automatically switched to adapt to the current network bandwidth.
    Different playback speeds can be specified, videos can be flipped horizontally, and hardware acceleration can be enabled.
    For more information about all capabilities of the player, see Overview.

    Player configuration APIs

    API
    Description
    Sets the player configuration information. For more information on the configuration, see TXVodPlayConfig.
    Sets the player's rendering view TXCloudVideoView.
    Sets the player's rendering view TextureView.
    Sets the player's rendering view SurfaceView.
    Sets the player business parameters in the format of <String,Object>.

    Basic playback APIs

    API
    Description
    Starts playing back the video at the specified HTTP URL.
    Starts playing back the video of the specified fileId by passing in the TXPlayInfoParams parameter.
    Plays back a DRM-encrypted video.
    Stops playback.
    Gets whether playback is ongoing.
    Pauses playback by stopping the retrieval of stream data and retaining the last-frame image.
    Resumes playback by getting the stream data again.
    Seeks to a specified time point of the video stream (in seconds).
    Seeks to a specified time point of the video stream (in ms).
    Gets the current playback time point in seconds.
    Gets the total buffer duration in seconds.
    Gets the total video duration in seconds.
    Gets the playable video duration in seconds.
    Gets the video width.
    Gets the video height.
    Sets whether to start VOD automatically after call of startPlay. VOD starts automatically by default.
    Sets the playback start time.
    Sets the token for HLS encryption.
    Gets the encrypted playback key.
    Sets whether to loop the video.
    Returns the loop playback status.

    Video APIs

    API
    Description
    Enables/Disables video hardware decoding.
    Gets the current video frame image.
    Note: Because this operation is time-consuming, the screenshot will be called back asynchronously.
    Sets whether to flip the video image horizontally.
    Sets the VOD playback speed. Default value: 1.0.
    Returns the current playback bitrate index.
    Returns the supported bitrates (definitions) if the playback address is HLS.
    Sets the current playback bitrate index for seamless definition switch. You may need to wait momentarily to switch the definition.
    Sets the image fill mode.

    Audio APIs

    API
    Description
    Sets whether to mute the player.
    Sets the volume level. Value range: 0–100.
    Sets whether to get the audio focus automatically. The audio focus is gotten automatically by default.

    Event notification APIs

    API
    Description
    Sets the player callback (this API has been deprecated, and we recommend you use setVodListener).
    Sets the player callback.

    TRTC APIs

    You can use the following APIs to push the audio/video streams of the VOD player through TRTC. For more information on TRTC services, see the TRTC Overview page.
    API
    Description
    Binds VOD to TRTC.
    Unbinds VOD from TRTC.
    Starts pushing the video stream.
    Cancels pushing the video stream.
    Starts pushing the audio stream.
    Cancels pushing the audio stream.

    ITXVodPlayListener

    VOD callback notifications.

    Basic SDK callback APIs

    API
    Description
    VOD playback event notification. For more information, see the playback event list and event parameters.

    TXVodPlayConfig

    VOD player configuration class.

    Basic configuration APIs

    API
    Description
    Sets the maximum number of player reconnection attempts.
    Sets the player reconnection interval in seconds.
    Sets the player connection timeout period in seconds.
    Sets the VOD cache directory, which takes effect for MP4 and HLS files.
    This API has been deprecated and is not recommended.
    Sets the maximum number of cached files.
    This API has been deprecated and is not recommended.
    Sets the player type.
    This API has been deprecated and is not recommended.
    Sets custom HTTP headers.
    Sets whether to enable accurate seek. Default value: true.
    If it is set to YES, the MP4 file will be automatically rotated according to the rotation angle set in the file, which can be obtained from the PLAY_EVT_CHANGE_ROTATION event. Default value: YES
    Sets whether to enable smooth switching for multi-bitrate HLS streams. Default value: false.
    Sets the cached MP4 file extension.
    Sets the progress callback interval in ms.
    Sets the maximum preloading buffer size in MB.
    Sets the maximum preloading buffer size in MB.
    Sets the extended information.
    Starts playing back the most preferred bitstream according to the configured preferredResolution if there are multiple HLS bitstreams. Here, preferredResolution is the product of the video width and height (width x height) and can only take effect if it is set before playback starts.
    Sets the HLS security hardening encryption and decryption key.
    Sets the HLS security hardening encryption and decryption IV.
    Sets whether to allow postrendering and postproduction features.
    Sets the media asset type, which is auto by default.

    TXPlayerGlobalSetting

    Global configuration of the VOD player.
    API
    Description
    Sets the cache directory of the playback engine. After setting, this directory will be first read and written during downloading, predownloading, and player use.
    Sets the maximum cache size in MB of the playback engine. After setting, the backend will clear files in the cache directory automatically according to the set value.

    TXVodPreloadManager

    Predownloading API class of the VOD player.
    API
    Description
    Gets the TXVodPreloadManager instance object in singleton mode.
    Sets the playback engine cache directory before starting predownloading.
    Stops predownloading.

    ITXVodPreloadListener

    The callback for video predownloading.
    API
    Description
    Video predownloading is completed.
    An error occurred during video predownload.

    TXVodDownloadManager

    Video download API class of the VOD player. Currently, only non-nested M3U8 videos can be downloaded. SimpleAES-encrypted videos will be encrypted again with Tencent Cloud's private encryption algorithm to improve the security.
    API
    Description
    Gets the TXVodDownloadManager instance object in singleton mode.
    Sets download HTTP headers.
    Sets the download callback method, which must be set before download.
    Starts downloading the video at the specified URL.
    Starts downloading the video of the specified fileid.
    Stops the download. If ITXVodDownloadListener.onDownloadStop is called back, the download stops successfully.
    Deletes the download information.
    Gets the download lists of all users.
    Gets the download information.
    Gets the download information.

    ITXVodDownloadListener

    VOD download notifications.
    API
    Description
    Download started.
    The download progress was updated.
    Download stopped.
    Download ended.
    An error occurred during download.
    Verifies the decryption key by the player if an encrypted file is found during HLS stream download.

    TXVodDownloadDataSource

    Tencent Cloud video fileid download source, which can be passed in as a parameter during download.
    API
    Description
    Builds a function to pass in parameters such as appid, fileid, quality, psign, and username.
    Gets the appid that is passed in.
    Gets the fileid that is passed in.
    Gets the psign that is passed in.
    Gets the quality that is passed in.
    Gets the userName that is passed in, which is default by default.
    Gets the token that is passed in.
    Gets the overlayKey that is passed in.
    Gets the overlayIv that is passed in.

    Definition ID constants

    Code
    Constant Definition
    Description
    0
    Original
    1
    LD
    2
    SD
    3
    HD
    4
    FHD
    5
    2K
    6
    4K
    1000
    Undefined

    TXVodDownloadMediaInfo

    Class to get VOD download information such as download progress and playback link.
    API
    Description
    Gets the download source specified by the fileid passed in for video download by fileid.
    Gets the total duration of the downloaded video.
    Gets the playable duration of the downloaded video.
    Gets the total size of the file being downloaded. This API takes effect only for download by fileid.
    Gets the size of the downloaded file. This API takes effect only for download by fileid.
    Gets the current download progress.
    Gets the current playback path, which can be passed in to TXVodPlayer for playback.
    Gets the download status.
    Determines whether the download is completed.

    Static attributes

    Code
    Attribute Definition
    Description
    0
    Download was initialized.
    1
    Download started.
    2
    Download stopped.
    3
    An error occurred during download.
    4
    Download was completed.

    TXPlayerAuthBuilder

    The configuration for encrypted video playback through fileId.
    API
    Description
    The application's appId.
    The file ID.
    The encrypted link timeout timestamp.
    The preview duration.
    The unique request ID.
    The hotlink protection signature.
    Whether to use HTTPS requests.

    TXBitrateItem

    The video bitrate information.
    API
    Description
    The number of the stream in the m3u8 file.
    The video width of this stream.
    The video height of this stream.
    The video bitrate of this stream.
    Whether the bitrates of two streams are the same.

    TXImageSprite

    The image sprite parsing class.
    API
    Description
    Constructor.
    Sets the image sprite URL.
    Gets a thumbnail.
    This API must be called after use; otherwise, memory leaks will occur.

    TXPlayerDrmBuilder

    The DRM playback information.
    API
    Description
    Constructs a DRM playback information object.
    Sets the URL of the certificate provider.
    Sets the URL of the decryption key.
    Sets the URL of the media file to be played back.

    TXPlayInfoParams

    Parameters for video playback through fileId.
    API
    Description
    Constructor.
    Gets the application's appId.
    Gets the file ID.
    Gets the encryption signature of a video.

    Error Codes

    Normal events

    Code
    Event Definition
    Description
    2004
    PLAY_EVT_PLAY_BEGIN
    Video playback started, and the loading icon animation (if any) ended.
    2005
    PLAY_EVT_PLAY_PROGRESS
    Video playback progress (including the current playback progress, loading progress, and total video duration).
    2007
    PLAY_EVT_PLAY_LOADING
    The video is being loaded. The LOADING_END event will be reported if video playback resumes.
    2014
    PLAY_EVT_VOD_LOADING_END
    Video loading ended, and video playback resumed.
    2006
    PLAY_EVT_PLAY_END
    Video playback ended.
    2013
    PLAY_EVT_VOD_PLAY_PREPARED
    The player has been prepared and can start playback.
    2003
    PLAY_EVT_RCV_FIRST_I_FRAME
    The network received the first renderable video data packet (IDR).
    2009
    PLAY_EVT_CHANGE_RESOLUTION
    The video resolution changed.
    2011
    PLAY_EVT_CHANGE_ROTATION
    The MP4 video was rotated.

    Warnings

    Code
    Event Definition
    Description
    -2301
    PLAY_ERR_NET_DISCONNECT
    The network was disconnected and could not be reconnected after multiple retries. You can restart the player to perform more connection retries.
    -2305
    PLAY_ERR_HLS_KEY
    Failed to get the HLS decryption key.
    2101
    PLAY_WARNING_VIDEO_DECODE_FAIL
    Failed to decode the current video frame.
    2102
    PLAY_WARNING_AUDIO_DECODE_FAIL
    Failed to decode the current audio frame.
    2103
    PLAY_WARNING_RECONNECT
    The network was disconnected, and automatic reconnection was performed (the PLAY_ERR_NET_DISCONNECT event will be thrown after three failed attempts).
    2106
    PLAY_WARNING_HW_ACCELERATION_FAIL
    Failed to start the hardware decoder, and the software decoder was used instead.
    -2304
    PLAY_ERR_HEVC_DECODE_FAIL
    Failed to decode with H.265.
    -2303
    PLAY_ERR_FILE_NOT_FOUND
    The file to be played back does not exist.

    Player SDK Constants

    The following constants are made available through TXVodConstants starting from v10.0:

    Image fill mode

    Code
    Event Definition
    Description
    0
    The video image is scaled proportionally to fill the entire screen.
    1
    The video image is scaled proportionally to fit the screen.

    Image rendering angle

    Code
    Event Definition
    Description
    0
    Normal portrait mode.
    270
    Landscape mode (90-degree clockwise rotation).

    Playback event list

    Code
    Event Definition
    Description
    2003
    The network received the first renderable video data packet (IDR).
    2004
    Video playback started.
    2005
    The video playback progress was changed.
    2006
    Video playback ended.
    2007
    The video is loading.
    2008
    The decoder started.
    2009
    The video resolution changed.
    2010
    Obtained the VOD file information successfully.
    2011
    The video is rotated.
    2013
    The video is loaded.
    2014
    Loading ended.
    2026
    The audio is played back for the first time.
    2103
    Network disconnected. Automatic reconnection has been enabled.
    -2301
    The network was disconnected and could not be reconnected after multiple retries.
    -2303
    The file does not exist.
    -2304
    Failed to decode with H.265.
    -2305
    Failed to get the HLS decryption key.
    -2306
    Failed to get the VOD file information.
    2106
    Failed to start the hardware decoder, and the software decoder was used instead.
    -5
    The license was invalid, and playback failed.

    Playback event parameters

    Event Definition
    Description
    The UTC time
    The event occurrence time
    The event description
    Event parameter 1
    Event parameter 2
    The video thumbnail
    The video URL
    The video name
    The video description
    The playback progress in milliseconds
    The total playback duration in milliseconds
    The playback progress
    The total playback duration
    The playable duration of the VOD file in milliseconds
    The playback speed
    The playable duration of the VOD file
    The download URL of the image sprite WebVTT file
    The download URL of the image sprite
    The encryption type
    The video codec type
    The video keyframe description
    The keyframe time

    Playback network status notification parameters

    Event Definition
    Description
    The CPU utilization
    The resolution's width
    The resolution's height
    The current video frame rate
    The current video GOP
    The bitrate of the video data
    The bitrate of the audio data
    The network speed
    The number of audio frames
    The number of video frames
    The audio information of the current stream
    The network jitter status
    The connected server IP
    The current frame rate of the video output by the decoder
    The network quality

    Player asset types

    Code
    Event Definition
    Description
    0
    The auto type
    1
    The HLS VOD media asset for adaptive bitrate streaming
    2
    The HLS live stream media asset for adaptive bitrate streaming

    Uncategorized variables

    Code
    Event Definition
    Description
    -1
    The index for adaptive bitrate
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support