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

class  TXVodPlayer
 

Detailed Description

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


Data Structure Documentation

◆ TXVodPlayer

class TXVodPlayer
+ Inheritance diagram for TXVodPlayer:

Instance Methods

(id< TXLivePlayListener > delegate) - DEPRECATED_MSG_ATTRIBUTE
 
(void) - setupVideoWidget:insertIndex:
 
(void) - removeVideoWidget
 
(void) - setStartTime:
 
(int) - startVodPlay:
 
(int) - startPlayDrm:
 
(int) - startVodPlayWithParams:
 
(int) - stopPlay
 
(bool) - isPlaying
 
(void) - pause
 
(void) - resume
 
(int) - seek:
 
(float) - currentPlaybackTime
 
(float) - duration
 
(float) - playableDuration
 
(int) - width
 
(int) - height
 
(void) - setRenderRotation:
 
(void) - setRenderMode:
 
(void) - setMute:
 
(void) - setAudioPlayoutVolume:
 
(void) - snapshot:
 
(void) - setRate:
 
(NSArray< TXBitrateItem * > *) - supportedBitrates
 
(NSInteger) - bitrateIndex
 
(void) - setBitrateIndex:
 
(void) - setMirror:
 
(void) - attachTRTC:
 
(void) - detachTRTC
 
(void) - publishVideo
 
(void) - publishAudio
 
(void) - unpublishVideo
 
(void) - unpublishAudio
 
(void) - enterPictureInPicture
 
(void) - exitPictureInPicture
 
(void) - addSubtitleSource:name:mimeType:
 
(void) - selectTrack:
 
(void) - deselectTrack:
 
(NSArray< TXTrackInfo * > *) - getSubtitleTrackInfo
 
(NSArray< TXTrackInfo * > *) - getAudioTrackInfo
 
(void) - setExtentOptionInfo:
 

Class Methods

(NSString *) + getEncryptedPlayKey:
 
(BOOL) + isSupportPictureInPicture
 

Properties

id< TXVodPlayListenervodDelegate
 
id< TXVideoCustomProcessDelegate > videoProcessDelegate
 
BOOL enableHWAcceleration
 
TXVodPlayConfigconfig
 
BOOL isAutoPlay
 
NSString * token
 
BOOL loop
 

Method Documentation

◆ addSubtitleSource:name:mimeType:()

- (void) addSubtitleSource: (NSString *)  url
name: (NSString *)  name
mimeType: (TX_VOD_PLAYER_SUBTITLE_MIME_TYPE mimeType 

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, see TXVodSDKEventDef.h file for details

◆ attachTRTC:()

- (void) attachTRTC: (NSObject *)  trtcCloud

This API is used to attach the current vodPlayer to TRTC.

Parameters
trtcCloudThe TRTC instance pointer
Attention
This API is used to push the substream. After attachment, audio playback will be performed by TRTC.

◆ bitrateIndex()

- (NSInteger) bitrateIndex

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

◆ currentPlaybackTime()

- (float) currentPlaybackTime

This API is used to get the current playback time.

Returns
A value in seconds

◆ DEPRECATED_MSG_ATTRIBUTE()

- (id<TXLivePlayListener> delegate) DEPRECATED_MSG_ATTRIBUTE ("Use vodDelegate instead.") 

The event callback. We recommend you use vodDelegate.

◆ deselectTrack:()

- (void) deselectTrack: (NSInteger)  trackIndex

Deselect track

Parameters
trackIndexTrack index

◆ detachTRTC()

- (void) detachTRTC

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

◆ duration()

- (float) duration

This API is used to get the total video duration.

Returns
A value in seconds

◆ enterPictureInPicture()

- (void) enterPictureInPicture

This API is used to enter the PiP mode and must be called after Prepared.

◆ exitPictureInPicture()

- (void) exitPictureInPicture

This API is used to exit the PiP mode.

◆ getAudioTrackInfo()

- (NSArray<TXTrackInfo *> *) getAudioTrackInfo

Returns a list of audio track information

◆ getEncryptedPlayKey:()

+ (NSString *) getEncryptedPlayKey: (NSString *)  key

This API is used to get the encrypted playback key.

◆ getSubtitleTrackInfo()

- (NSArray<TXTrackInfo *> *) getSubtitleTrackInfo

Return subtitle track information list

◆ height()

- (int) height

The video height.

◆ isPlaying()

- (bool) isPlaying

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

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

◆ isSupportPictureInPicture()

+ (BOOL) isSupportPictureInPicture

This API is used to query whether the current device supports the picture-in-picture (PiP) feature. To use this feature, you need to first check whether the current device supports PiP.

◆ pause()

- (void) pause

Pauses playback

◆ playableDuration()

- (float) playableDuration

The playable duration.

Returns
A value in seconds

◆ publishAudio()

- (void) publishAudio

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

◆ publishVideo()

- (void) publishVideo

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

◆ removeVideoWidget()

- (void) removeVideoWidget

This API is used to remove the video rendering view.

◆ resume()

- (void) resume

This API is used to resume playback.

◆ seek:()

- (int) seek: (float)  time

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: (NSInteger)  trackIndex

Select track

Parameters
trackIndexTrack index

◆ setAudioPlayoutVolume:()

- (void) setAudioPlayoutVolume: (int)  volume

This API is used to set the volume level.

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

◆ setBitrateIndex:()

- (void) setBitrateIndex: (NSInteger)  index

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.

◆ setExtentOptionInfo:()

- (void) setExtentOptionInfo: (NSDictionary< NSString *, NSString * > *)  extInfo

Configure subtitle style

Parameters
renderModelSupport style reference TXPlayerSubtitleRenderModel /
  • (void) setSubtileStyle:(TXPlayerSubtitleRenderModel)renederModel;

/** This API is used to set extended option parameters.

◆ setMirror:()

- (void) setMirror: (BOOL)  isMirror

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

◆ setMute:()

- (void) setMute: (BOOL)  bEnable

This API is used to set muting.

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

◆ setRate:()

- (void) setRate: (float)  rate

This API is used to set the playback speed.

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

◆ setRenderMode:()

- (void) setRenderMode: (TX_Enum_Type_RenderMode)  renderMode

This API is used to set the image cropping mode.

Parameters
modeFill (the image may be stretched or cropped) or fit (there may be black color in unmatched areas). Default value: TRTCVideoFillMode_Fit.
Attention
Used for the window rendering mode

◆ setRenderRotation:()

- (void) setRenderRotation: (TX_Enum_Type_HomeOrientation)  rotation

This API is used to set the image orientation.

Set the clockwise rotation angle of the local image

Parameters
rotationiOS: Rotation angles of TRTCVideoRotation90, TRTCVideoRotation180, and TRTCVideoRotation270 are supported. Default value: TRTCVideoRotation0.
Attention
Used for the window rendering mode

◆ setStartTime:()

- (void) setStartTime: (CGFloat)  startTime

This API is used to set the playback start time.

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

◆ setupVideoWidget:insertIndex:()

- (void) setupVideoWidget: (UIView *)  view
insertIndex: (unsigned int)  idx 

This API is used to create the video rendering view. This control is used to display the video content.

◆ snapshot:()

- (void) snapshot: (void(^)(UIImage *))  snapshotCompletionBlock

snapshotCompletionBlock returns the current image through the callback.

◆ startPlayDrm:()

- (int) startPlayDrm: (TXPlayerDrmBuilder *)  drmBuilder

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:()

- (int) startVodPlay: (NSString *)  url

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.

◆ startVodPlayWithParams:()

- (int) startVodPlayWithParams: (TXPlayerAuthParams *)  params

This API is used to play back a file with the specified fileid.

Attention
Starting from version 10.7, you need to set the Licence through TXLiveBase#setLicence to play successfully, otherwise the playback will fail (black screen), and you can only set it once globally. Live broadcast licence, short video licence and video playback licence can be used. If you have not obtained the above licence, you can Apply for a licence quickly and for free to play normally.

◆ stopPlay()

- (int) stopPlay

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

Returns
Whether playback stopped successfully. Valid values: 0: yes; other values: no.

◆ supportedBitrates()

- (NSArray<TXBitrateItem *> *) supportedBitrates

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.

◆ unpublishAudio()

- (void) unpublishAudio

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

◆ unpublishVideo()

- (void) unpublishVideo

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

◆ width()

- (int) width

The video width.

Property Documentation

◆ config

- (TXVodPlayConfig*) config
readwritenonatomiccopy

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

◆ enableHWAcceleration

- (BOOL) enableHWAcceleration
readwritenonatomicassign

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

◆ isAutoPlay

- (BOOL) isAutoPlay
readwriteatomic

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

◆ loop

- (BOOL) loop
readwritenonatomicassign

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

◆ token

- (NSString*) token
readwritenonatomicstrong

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

◆ videoProcessDelegate

- (id<TXVideoCustomProcessDelegate>) videoProcessDelegate
readwritenonatomicweak

The callback for video rendering.

This callback is supported by both software and hardware decoders on all platforms.

◆ vodDelegate

- (id<TXVodPlayListener>) vodDelegate
readwritenonatomicweak

The event callback.