App Transport Security Settings->Allow Arbitrary Loads
to YES
in the info.plist
file of your project.GCDWebServer
component dependency. pod "GCDWebServer", "~> 3.0"
TXCPlayerAdapter
, and videos can be played back after it is created.fileId
is usually returned by the server after the video is uploaded:fileId
to the client.fileId
will be included in the notification of upload confirmation.NSInteger appId; //// `appid` can be applied for in Tencent Cloud VODNSString *fileId;// `psign` is a player signature. For more information on the signature and how to generate it, visit https://www.tencentcloud.com/document/product/266/42436?from_cn_redirect=1.NSString *pSign = self.pSignTextView.text;TXCPlayerAdapter *adapter = [TXCPlayerAdapter shareAdapterWithAppId:appId];
id<ITXCPlayerAssistorProtocol> assistor = [TXCPlayerAdapter createPlayerAssistorWithFileId:fileId pSign:pSign];[assistor requestVideoInfo:^(id<ITXCPlayerAssistorProtocol> response, NSError *error) {if (error){NSLog(@"create player assistor error : %@",error);[self.view makeToast:error.description duration:5.0 position:CSToastPositionBottom];return;}[weakSelf avplayerPlay:response]; // Play back the video}];- (void)avplayerPlay:(id<ITXCPlayerAssistorProtocol>)response{AVPlayerViewController *playerVC = [[AVPlayerViewController alloc] init];self.playerVC = playerVC;TXCStreamingInfo *info = response.getStreamingInfo;AVPlayer *player = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:info.playUrl]];playerVC.player = player;playerVC.title = response.getVideoBasicInfo.name;[self.navigationController pushViewController:playerVC animated:YES];[player addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];}
[TXCPlayerAdapter destroy];
+ (instancetype)shareAdapterWithAppId:(NSUInteger)appId;
appid
(if a subapplication is used, enter the subappid
). |+ (void)destroy;
fileId
and process DRM encryption APIs.+ (id<ITXCPlayerAssistorProtocol>)createPlayerAssistorWithFileId:(NSString *)fileIdpSign:(NSString *)pSign;
Parameter | Type | Description |
fileId | String | The fileId of the video to be played. |
pSign | String | The player signature. |
- (void)requestVideoInfo:(ITXCRequestVideoInfoCallback)completion;
Parameter | Type | Description |
completion | ITXCRequestVideoInfoCallback | Async callback function. |
+ (void)destroyPlayerAssistor:(id<ITXCPlayerAssistorProtocol>)assistor;
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
is called back.- (TXCVideoBasicInfo *)getVideoBasicInfo;
TXCVideoBasicInfo
are as follows:Parameter | Type | Description |
name | String | Video name |
size | Int | Video size in bytes |
duration | Float | Video duration in seconds |
description | String | Video description |
coverUrl | String | Video cover |
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
is called back.- (TXCStreamingInfo *)getStreamingInfo;
TXCStreamingInfo
are as follows:Parameter | Type | Description |
playUrl | String | Playback URL |
subStreams | List |
TXCSubStreamInfo
are as follows:Parameter | Type | Description |
type | String | Substream type. Valid values: video |
width | Int | The substream video width in px. |
height | Int | The substream video height in px. |
resolutionName | String | The name of the substream video displayed in the player. |
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
is called back.- (NSArray<TXCKeyFrameDescInfo *> *)getKeyFrameDescInfos;
TXCKeyFrameDescInfo
are as follows:Parameter | Type | Description |
timeOffset | Float | 1.1 |
content | String | "Beginning now..." |
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
is called back.- (TXCImageSpriteInfo *)getImageSpriteInfo;
TCXImageSpriteInfo
are as follows:Parameter | Type | Description |
imageUrls | List | Array of thumbnail download URLs of String type. |
webVttUrl | String | Thumbnail VTT file download URL. |
Was this page helpful?