V2TXLivePlayer

Last updated: 2021-07-16 18:40:03

Feature

/// This player pulls audio and video data from the specified live streaming URL and plays the data after decoding and local rendering.

Overview

/// The player has the following capabilities:

/// - View capturing, which allows you to capture the video images of the current live stream.
/// - 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 live stream based on the project requirements.

Basic SDK APIs

setObserver

- (void)setObserver:(id<TXLivePlayerObserver>)observer;

Parameters

Parameter Type Description

Basic Playback APIs

setRenderView

- (V2TXLiveCode)setRenderView:(TXView *)view;

Parameters

Parameter Type Description

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

startPlay

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

- (TXLiveCode)startPlay:(NSString *)url;

Parameters

Parameter Type Description

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful
  • V2TXLIVE_ERROR_INVALID_PARAMETER: failed to publish streams because the URL is invalid.
  • V2TXLIVE_ERROR_REFUSED: you cannot use the same stream ID for push and pull on the same device.

stopPlay

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

- (TXLiveCode)stopPlay;

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

isPlaying

- (int)isPlaying;

Response

Whether streams are being published

    • 1: yes
    • 0: no

Video APIs

setRenderRotation

- (V2TXLiveCode)setRenderRotation:(V2TXLiveRotation)rotation; 

Parameters

Parameter Type Description
rotation V2TXLiveRotation Degrees by which the image is rotated. Default value: V2TXLiveRotation0

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

V2TXLiveRotation enumerated values

Value Description
V2TXLiveRotation0 No rotation
V2TXLiveRotation90 Rotate 90 degrees clockwise
V2TXLiveRotation180 Rotate 180 degrees clockwise
V2TXLiveRotation270 Rotate 270 degrees clockwise

- (TXLiveCode)setRenderFillMode:(TXLiveFillMode)mode;

Parameters

Parameter Type Description

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

| -------------------- | ------------------------------------------------------------ |
| TXLiveFillMode_Fit | 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 |
| TXLiveFillMode_Fill | Fill the image on the screen without leaving any black edges. If the aspect ratio of the view is different from that of the screen, part of the view content will be cropped |


pauseVideo

- (TXLiveCode)pauseVideo;

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

- (TXLiveCode)resumeVideo;

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

snapshot

Note:

After V2TXLIVE_OK is returned, you can get the screenshot taken in the V2TXLivePusherObserver.onSnapshotComplete callback.

- (V2TXLiveCode)snapshot;

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful
  • V2TXLIVE_ERROR_REFUSED: failed to take a screenshot because publishing has stopped

This API is used to set custom rendering for local video.

  • Using this method, you can obtain every frame of the video view after decoding, perform custom rendering, and add custom display effects.
- (V2TXLiveCode)enableCustomVideoCapture:(BOOL)enable;
                        | pixelFormat | [V2TXLivePixelFormat](#V2TXLivePixelFormat) | Pixel format of video frames |
                         bufferType:(TXLiveBufferType)bufferType

Parameters

Parameter Type Description
enable BOOL Whether to enable small image encoding. Default value: NO.
* @param pixelFormat Video pixel format for custom rendering callback {@link TXLivePixelFormat}.

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful
    • TXLIVE_ERROR_NOT_SUPPORTED: the pixel format or data format is not supported.

V2TXLivePixelFormat enumerated values

Value Description
V2TXLivePixelFormatUnknown Unknown
V2TXLivePixelFormatI420 YUV420P/I420

| V2TXLivePixelFormatTexture2D | OpenGL 2D texture |

V2TXLiveBufferType enumerated values

| ----------------------------- | ------------------------------------------------------------ |

| TRTCVideoBufferType_PixelBuffer | It is most efficient when used directly. The iOS system provides various APIs to get or process PixelBuffer.|
/// The performance may be compromised. As the SDK processes PixelBuffer directly, switching between NSData and PixelBuffer will result in memory copying overhead.


Audio APIs

- (TXLiveCode)pauseAudio; 

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

- (TXLiveCode)resumeAudio; 

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

This API is used to set volume.

- (TXLiveCode)setPlayoutVolume:(NSUInteger)volume;

Parameters

Parameter Type Description

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

enableVolumeEvaluation

This API is used to enable the volume reminder.

  • After this feature is enabled, you can obtain the SDK’s volume evaluation through the [onPlayoutVolumeUpdate](@ref TXLivePlayerObserver#onPlayoutVolumeUpdate:volume:) callback.
    - (V2TXLiveCode)enableVolumeEvaluation:(NSUInteger)intervalMs;
    

Parameters

Parameter Type Description
intervalMs int Interval (ms) for volume callbacks. The minimum interval allowed is 100 ms. If the value is 0 (default) or smaller, the callback is disabled. 300 is recommended.

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful

Other APIs

- (TXLiveCode)setCacheParams:(CGFloat)minTime maxTime:(CGFloat)maxTime;

Parameters

Parameter Type Description

Response

V2TXLiveCode:

  • V2TXLIVE_OK: successful
    • TXLIVE_ERROR_INVALID_PARAMETER: operation failed. minTime and maxTime must be greater than 0.

showDebugView

- (void)showDebugView:(BOOL)isShow; 

Parameters

Parameter Type Description