Tencent Cloud live player.
This player pulls audio and video data from the specified livestreaming URL and plays the data after decoding and local rendering.
The player has the following capabilities:
- Supports RTMP, HTTP-FLV and TRTC.
- View capturing, which allows you to capture the video images of the current livestream.
- Delay adjustment, which allows you to set the minimum time and maximum time for auto adjustment of the player cache.
- Custom video data processing, which allows you to perform rendering and play video data after processing video data in the livestream based on the project requirements.
◆ com::tencent::live2::V2TXLivePlayer
class com::tencent::live2::V2TXLivePlayer |
◆ setObserver()
Sets the player callback.
By setting the callback, you can listen to some callback events of V2TXLivePlayer, including the player status, playback volume callback, first frame audio/video callback, statistics, warnings, and error messages.
- Parameters
-
◆ setRenderView() [1/3]
abstract int setRenderView |
( |
TXCloudVideoView |
view | ) |
|
|
abstract |
Sets the rendering view of the player. This control is responsible for presenting the video content.
- Parameters
-
view | Player rendering view. |
- Returns
- Return code V2TXLiveCode
◆ setRenderView() [2/3]
abstract int setRenderView |
( |
TextureView |
view | ) |
|
|
abstract |
Sets the rendering view of the player. This control is responsible for presenting the video content.
- Parameters
-
view | Player rendering view. |
- Returns
- Return code V2TXLiveCode
◆ setRenderView() [3/3]
abstract int setRenderView |
( |
SurfaceView |
view | ) |
|
|
abstract |
Sets the rendering view of the player. This control is responsible for presenting the video content.
- Parameters
-
view | Player rendering view. |
- Returns
- Return code V2TXLiveCode
◆ setRenderRotation()
Sets the rotation angle of the player view.
- Parameters
-
rotation | Rotation angle of the view V2TXLiveRotation
- V2TXLiveRotation0 [Default]: 0 degrees, which means the view is not rotated.
- V2TXLiveRotation90: rotate 90 degrees clockwise.
- V2TXLiveRotation180: rotate 180 degrees clockwise.
- V2TXLiveRotation270: rotate 270 degrees clockwise.
|
- Returns
- Return code V2TXLiveCode
◆ setRenderFillMode()
Sets the fill mode of the view.
- Parameters
-
mode | Fill mode of the view V2TXLiveFillMode。
- V2TXLiveFillModeFit [Default]: make the view fit the screen without cropping. If the aspect ratio of the view is different from that of the screen, black edges will appear.
- V2TXLiveFillModeFill: fill the screen with the image without leaving any black edges. If the aspect ratio of the view is different from that of the screen, part of the view will be cropped.
|
- Returns
- Return code V2TXLiveCode
◆ startPlay()
abstract int startPlay |
( |
String |
url | ) |
|
|
abstract |
Starts playing the audio and video streams.
- Parameters
-
url | URL of the audio and video streams to be played. The RTMP, HTTP-FLV and TRTC streaming protocols are supported. |
- Returns
- Return code V2TXLiveCode
- V2TXLIVE_OK: operation succeeded. The player starts connecting to the URL and playing the audio and video streams.
- V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. The URL is invalid.
- V2TXLIVE_ERROR_REFUSED: operation failed. Duplicate streamId, please ensure that no other player or pusher is using this streamId now.
◆ stopPlay()
abstract int stopPlay |
( |
| ) |
|
|
abstract |
Stops playing the audio and video streams.
- Returns
- Return code V2TXLiveCode
◆ isPlaying()
abstract int isPlaying |
( |
| ) |
|
|
abstract |
Indicates whether the player is playing the audio and video streams.
- Returns
- Indicates whether the player is playing the audio and video streams.
◆ pauseAudio()
abstract int pauseAudio |
( |
| ) |
|
|
abstract |
Pauses the audio stream of the player.
- Returns
- Return code V2TXLiveCode
◆ resumeAudio()
abstract int resumeAudio |
( |
| ) |
|
|
abstract |
Resumes the audio stream of the player.
- Returns
- Return code V2TXLiveCode
◆ pauseVideo()
abstract int pauseVideo |
( |
| ) |
|
|
abstract |
Pauses the video stream of the player.
- Returns
- Return code V2TXLiveCode
◆ resumeVideo()
abstract int resumeVideo |
( |
| ) |
|
|
abstract |
Resumes the video stream of the player.
- Returns
- Return code V2TXLiveCode
◆ setPlayoutVolume()
abstract int setPlayoutVolume |
( |
int |
volume | ) |
|
|
abstract |
Sets the volume.
- Parameters
-
volume | Volume. Valid range: 0 - 100. [Default]: 100 |
- Returns
- Return code V2TXLiveCode
◆ setCacheParams()
abstract int setCacheParams |
( |
float |
minTime, |
|
|
float |
maxTime |
|
) |
| |
|
abstract |
Set the minimum time and maximum time (unit: ms) for auto adjustment of the player cache.
- Parameters
-
minTime | Minimum time for auto cache adjustment. The value must be greater than 0. [Default]: 1 |
maxTime | Maximum time for auto cache adjustment. The value must be greater than 0. [Default]: 5 |
- Returns
- Return code V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. MinTime and maxTime must be greater than 0.
- V2TXLIVE_ERROR_REFUSED: operation failed. Change of cache is not suppoted when playing.
◆ enableVolumeEvaluation()
abstract int enableVolumeEvaluation |
( |
int |
intervalMs | ) |
|
|
abstract |
Enables playback volume update.
After this feature is enabled, you can obtain the SDK’s volume evaluation through the onPlayoutVolumeUpdate callback.
- Parameters
-
intervalMs | Interval for triggering the volume callback. The unit is ms. The minimum interval is 100 ms. If the value is equal to or smaller than 0, the callback is disabled. We recommend that you set this parameter to 300 ms. [Default]: 0. |
- Returns
- Return code V2TXLiveCode
◆ snapshot()
abstract int snapshot |
( |
| ) |
|
|
abstract |
Captures the video view in the playback process.
- Returns
- Return code V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_REFUSED: playback is stopped, the snapshot operation cannot be called.
◆ enableCustomRendering()
Sets the custom video rendering callback.
Using this method, you can obtain every frame of the video view after decoding, perform custom rendering, and add custom display effects.
- Parameters
-
enable | Whether to enable custom rendering. [Default]: NO |
pixelFormat | Video pixel format for custom rendering callback V2TXLivePixelFormat。 |
bufferType | Video data format for custom rendering callback V2TXLiveBufferType。 |
- Returns
- Return code V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_NOT_SUPPORTED: the pixel format or data format is not supported.
◆ showDebugView()
abstract void showDebugView |
( |
boolean |
isShow | ) |
|
|
abstract |
Indicates whether the debug view of the player video status information is displayed.
- Parameters
-
isShow | Specifies whether to display the debug view. [Default]: NO. |
◆ setProperty()
abstract int setProperty |
( |
String |
key, |
|
|
Object |
value |
|
) |
| |
|
abstract |
Calls the advanced API of V2TXLivePlayer.
- Attention
- This API is used to call some advanced features.
- Parameters
-
key | Key of the advanced API. |
value | Parameter needed to call the advanced API corresponding to the key. |
- Returns
- Return code V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. The key cannot be nil.