tencent cloud

Feedback

API Documentation

Last updated: 2022-08-10 17:15:41

    TXVodPlayer

    VOD player

    For more information, 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.
    • Video resolution can be switched manually or can switch automatically to adapt to 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
    config Configures VOD. For more information on the configuration, see TXVodPlayConfig.
    isAutoPlay Sets whether to start playback immediately after call of startPlay. Default value: YES.
    token Sets the token for HLS encryption. After the token is set, the player will automatically add voddrm.token.TOKEN TextureView before the filename in the URL.
    loop Sets whether to loop SurfaceView.
    enableHWAcceleration Sets whether to enable hardware acceleration.
    setExtentOptionInfo Sets the player business parameters in the format of <nsstring *,="" id="">.

    Basic playback APIs

    API Description
    startPlay Starts playing back the video at the specified HTTP URL.
    startPlayWithParams Starts playing back the video of the specified fileId.
    stopPlay Stops playback.
    isPlaying Gets whether playback is ongoing.
    pause Pauses playback by stopping getting the stream data and retaining the last-frame image.
    resume Resumes playback by getting the stream data again.
    seek Seeks to the specified time point of a video stream (in seconds).
    currentPlaybackTime Gets the current playback time point in seconds.
    duration Gets the total video duration in seconds.
    playableDuration Gets the playable video duration in seconds.
    width Gets the video width.
    height Gets the video height.
    setStartTime Sets the playback start time.

    Video APIs

    API Description
    snapshot Gets the current video frame image.
    Note: As this operation is time-consuming, the screenshot will be called back asynchronously.
    setMirror Sets whether to flip the video image horizontally.
    setRate Sets the VOD playback speed. Default value: 1.0.
    bitrateIndex Returns the current playback bitrate index.
    setBitrateIndex Sets the current playback bitrate index for seamless definition switch.
    You may need to wait momentarily to switch the definition.
    setRenderMode Sets the image fill mode.
    setRenderRotation Sets the image rendering angle.

    Audio APIs

    API Description
    setMute Sets whether to mute the player.
    setAudioPlayoutVolume Sets the volume level. Value range: 0–100.

    Event notification APIs

    API Description
    delegate Event callback. We recommend you use vodDelegate.
    vodDelegate Sets the player callback.
    videoProcessDelegate Sets the video rendering callback (supported by hardware encoding only).

    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
    attachTRTC Binds VOD to TRTC.
    detachTRTC Unbinds VOD from TRTC.
    publishVideo Starts pushing the video stream.
    unpublishVideo Cancels pushing the video stream.
    publishAudio Starts pushing the audio stream.
    unpublishAudio Cancels pushing the audio stream.

    TXVodPlayListener

    VOD callback notifications.

    Basic SDK callback APIs

    API Description
    onPlayEvent VOD playback event notification. For more information, see the playback event list and event parameters.
    onNetStatus Network status notification of the VOD player.

    TXVodPlayConfig

    VOD player configuration class.

    Basic configuration APIs

    API Description
    connectRetryCount Sets the maximum number of player reconnection attempts.
    connectRetryInterval Sets the player reconnection interval in seconds.
    timeout Sets the player connection timeout period in seconds.
    cacheFolderPath Sets the VOD cache directory, which takes effect for MP4 and HLS files.
    maxCacheItems Sets the maximum number of cached files.
    playerType Sets the player type.
    headers Sets custom HTTP headers.
    enableAccurateSeek Sets whether to enable accurate seek. Default value: true.
    autoRotate 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
    smoothSwitchBitrate Sets whether to enable smooth switch for multi-bitrate HLS streams. Default value: false.
    progressInterval Sets the progress callback interval in ms.
    maxBufferSize Sets the maximum preloading buffer size in MB.
    maxPreloadSize Sets the maximum preloading buffer size in MB.
    firstStartPlayBufferTime Sets the duration of the video data that needs to be loaded during the first buffering in ms. Default value: 100 ms.
    nextStartPlayBufferTime Sets the minimum buffered data size to stop buffering (secondary buffering for insufficient buffered data or progress bar drag buffering caused by seek) in ms. Default value: 250 ms.
    overlayKey Sets the HLS security hardening encryption and decryption key.
    overlayIv Sets the HLS security hardening encryption and decryption IV.
    extInfoMap Sets the extended information.
    preferredResolution 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 and can only take effect if it is set before playback starts.
    enableRenderProcess Sets whether to allow postrendering and postproduction features such as super-resolution plugin, which is enabled by default.

    TXPlayerGlobalSetting

    Global configuration of the VOD player.

    API Description
    setCacheFolderPath Sets the cache directory of the playback engine. After setting, this directory will be first read and written during predownloading and player use.
    setMaxCacheSize 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
    sharedManager Gets the TXVodPreloadManager instance object in singleton mode.
    startPreload Sets the playback engine cache directory (TXPlayerGlobalSetting#setCacheFolderPath) and cache size (TXPlayerGlobalSetting#setMaxCacheSize) before starting predownloading.
    stopPreload Stops predownloading.

    TXVodDownloadManager

    Video download API class of the VOD player.

    API Description
    shareInstance Gets the TXVodDownloadManager instance object in singleton mode.
    setDownloadPath Sets the download root directory.
    setHeaders Sets download HTTP headers.
    setListener Sets the download callback method, which must be set before download.
    startDownloadUrl Starts downloading the video at the specified URL.
    startDownload Starts downloading the video of the specified FileID.
    stopDownload Stops the download. If ITXVodDownloadListener.onDownloadStop is called back, the download stops successfully.
    deleteDownloadFile Deletes the downloaded file.
    deleteDownloadMediaInfo Deletes the download information.
    getDownloadMediaInfoList Gets the download lists of all users.

    ITXVodDownloadListener

    VOD download notifications.

    API Description
    onDownloadStart Download started.
    onDownloadProgress The download progress was updated.
    onDownloadStop Download stopped.
    onDownloadFinish Download ended.
    onDownloadError An error occurred during download.
    hlsKeyVerify Verifies the decryption key by the player if an encrypted file is found during HLS stream download.

    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.

    Warning events

    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.
    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