The VOD player API class
The player has the following capabilities:
- A rich set of audio/video formats are supported, such as RTMP, FLV, HLS, MP4, and WebRTC
- Online videos can be played back at URLs. A URL can be a VOD playback address or the pull address of a live stream
- Videos can be played back through their
FileID
in VOD
- The specified position can be quickly and accurately located to play back the video image there
◆ TXVodPlayer
◆ addSubtitleSource:name:mimeType:()
Add external subtitles
- Parameters
-
url | Subtitle address |
name | The 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. |
mimeType | Subtitle 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
-
trtcCloud | The 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
-
◆ detachTRTC()
This API is used to detach the current vodPlayer
from TRTC.
◆ 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()
Returns a list of audio track information
◆ getEncryptedPlayKey:()
+ (NSString *) getEncryptedPlayKey: |
|
(NSString *) |
key |
|
This API is used to get the encrypted playback key.
◆ getSubtitleTrackInfo()
Return subtitle track information list
◆ height()
◆ 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()
◆ playableDuration()
- (float) playableDuration |
|
|
|
The playable duration.
- Returns
- A value in seconds
◆ publishAudio()
This API is used to start pushing the audio substream to TRTC.
◆ 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()
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
-
time | The video stream time point in seconds |
◆ selectTrack:()
- (void) selectTrack: |
|
(NSInteger) |
trackIndex |
|
◆ setAudioPlayoutVolume:()
- (void) setAudioPlayoutVolume: |
|
(int) |
volume |
|
This API is used to set the volume level.
- Parameters
-
volume | Volume. 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
-
index | The bitrate index. index == -1 indicates to enable adaptive bitrate streaming for HLS files. |
◆ setExtentOptionInfo:()
- (void) setExtentOptionInfo: |
|
(NSDictionary< NSString *, NSString * > *) |
extInfo |
|
Configure subtitle style
- Parameters
-
/** 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
-
mute | Whether 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
-
rate | The 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
-
mode | Fill (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
-
rotation | iOS: 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
-
startTime | The 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:()
This API is used to start playing back a file encrypted with standard FairPlay DRM.
- Parameters
-
playerDrmBuilder | The 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
-
url | The URL of the stream to be played back |
- Returns
- Whether playback started successfully. Valid values: 0: yes; -1: no.
◆ startVodPlayWithParams:()
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()
This API is used to stop playing audio/video streams.
- Returns
- Whether playback stopped successfully. Valid values: 0: yes; other values: no.
◆ 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()
This API is used to stop pushing the audio substream to TRTC.
◆ unpublishVideo()
This API is used to stop pushing the video substream to TRTC.
◆ width()
◆ config
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
This API is used to set whether to start VOD automatically after call of startPlay
. VOD starts automatically by default.
◆ loop
This API is used to set whether to loop the playback.
◆ token
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