App Transport Security Settings->Allow Arbitrary Loads
设置为 YES。GCDWebServer
组件依赖。 pod "GCDWebServer", "~> 3.0"
TXCPlayerAdapter
,创建后即可播放视频。NSInteger appId; ////appid 在腾讯云点播申请NSString *fileId;//psign 即播放器签名,签名介绍和生成方式参见链接:https://www.tencentcloud.com/document/product/266/42436?from_cn_redirect=1NSString *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]; //播放视频}];- (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;
+ (void)destroy;
+ (id<ITXCPlayerAssistorProtocol>)createPlayerAssistorWithFileId:(NSString *)fileIdpSign:(NSString *)pSign;
参数名 | 类型 | 描述 |
fileId | String | 要播放的视频 fileId |
pSign | String | 播放器签名 |
- (void)requestVideoInfo:(ITXCRequestVideoInfoCallback)completion;
参数名 | 类型 | 描述 |
completion | ITXCRequestVideoInfoCallback | 异步回调函数 |
+ (void)destroyPlayerAssistor:(id<ITXCPlayerAssistorProtocol>)assistor;
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
回调之后才生效。- (TXCVideoBasicInfo *)getVideoBasicInfo;
参数名 | 类型 | 描述 |
name | String | 视频名称 |
size | Int | 视频大小,单位:字节 |
duration | Float | 视频时长,单位:秒 |
description | String | 视频描述 |
coverUrl | String | 视频封面 |
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
回调之后才生效。- (TXCStreamingInfo *)getStreamingInfo;
参数名 | 类型 | 描述 |
playUrl | String | 播放 URL |
subStreams | List | 自适应码流子流信息,类型为 TXCSubStreamInfo |
参数名 | 类型 | 描述 |
type | String | 子流的类型,目前可能的取值仅有 video |
width | Int | 子流视频的宽,单位:px |
height | Int | 子流视频的高,单位:px |
resolutionName | String | 子流视频在播放器中展示的规格名 |
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
回调之后才生效。- (NSArray<TXCKeyFrameDescInfo *> *)getKeyFrameDescInfos;
参数名 | 类型 | 描述 |
timeOffset | Float | 1.1 |
content | String | "片头开始..." |
id<ITXCPlayerAssistorProtocol>.requestVideoInfo
回调之后才生效。- (TXCImageSpriteInfo *)getImageSpriteInfo;
参数名 | 类型 | 描述 |
imageUrls | List | 缩略图下载 URL 数组,类型为 String |
webVttUrl | String | 缩略图 VTT 文件下载 URL |
本页内容是否解决了您的问题?