最近更新时间: 2026-02-10 14:30:10
七牛 Miku 超低延时协议直播构建了全新的快直播互动体验,相比于传统的直播能力降低了延时、优化了协议与底层技术,目前对于微信内直播多业务场景提供了更为优渥的使用体验。支持千万级并发同时拥有毫秒级开播体验,打通了用户对于直播低延时性的核心诉求。
CocoaPods 是针对 Objective-C 的依赖管理工具,它能够将使用类似 QNRTPlayerKit 的第三方库的安装过程变得非常简单和自动化,你能够用下面的命令来安装它:
$ sudo gem install cocoapods为了使用 CoacoaPods 集成 QNRTPlayerKit 到你的 Xcode 工程当中,你需要编写你的 Podfile
source 'https://github.com/CocoaPods/Specs.git'
target 'TargetName' do
pod 'QNRTPlayerKit'
endpod "QNRTPlayerKit", :podspec => 'https://raw.githubusercontent.com/pili-engineering/QNRTPlayer-iOS/master/QNRTPlayerKit-Universal.podspec'注意:鉴于目前 iOS 上架,只支持动态库真机,请在 App 上架前,更换至真机版本
然后,运行如下的命令:
$ pod install当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 issues 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 Labels 中指明类型为 bug 或者其他。
QNRTPlayer 为建立音视频播放的核心类,包含播放、停止,静音等接口。
@property (nonatomic, assign, readonly) QNRTPlayState playState;- (void)RTPlayer:(QNRTPlayer *)player playStateDidChange:(QNRTPlayState)playState; 方法回调。@property (nonatomic, weak) id<QNRTPlayerDelegate> delegate;@property (nonatomic, assign, readonly) BOOL isPlaying;@property (nonatomic, copy, readonly) NSURL *playUrl;@property (nonatomic, assign) NSUInteger statisticInterval;@property (nonatomic, assign) double volume;@property (nonatomic, assign, readonly) CGFloat width;@property (nonatomic, assign, readonly) CGFloat height;@property (nonatomic, strong) QNRTVideoView *playView;- (void)playWithUrl:(NSURL *)url supportHttps:(BOOL)isSupport;| 参数名 | 描述 |
|---|---|
| url | 需要播放的 url ,目前支持rtmp、hls、hdl和webrtc (url 以 webrtc:// 开头) 协议 |
| isSupport | 当前播放 URL 是否支持 SSL 证书,默认为 NO |
- (void)stop;- (void)muteAudio:(BOOL)mute;| 参数名 | 描述 |
|---|---|
| mute | 是否需要静音 |
- (void)muteVideo:(BOOL)mute;| 参数名 | 描述 |
|---|---|
| mute | 是否需要画面渲染 |
- (void)setSpeakerOn:(BOOL)speakerOn;| 参数名 | 描述 |
|---|---|
| speakerOn | 扬声器开关 |
- (void)takeScreenshotCallback:(QNScreenshotResultCallback)resultCallback;| 参数名 | 描述 |
|---|---|
| resultCallback | 截图的结果回调 |
- (void)setJitterBufferMinDelay:(double)jitterBufferMinDelay;| 参数名 | 描述 |
|---|---|
| jitterBufferMinDelay | 抖动缓冲区最小延迟 |
+ (void)enableFileLogging;注意:文件日志功能主要用于排查问题,打开文件日志功能会对性能有一定影响,上线前请记得关闭文件日志功能!
+ (NSString *)versionInfo;- (BOOL)isSupportPictureInPicture;- (void)startPictureInPicture;- (void)stopPictureInPicture;- (void)setPictureInPictureType:(QNRTVideoPictureInPictureType)type;QNRTPlayerDelegate 在 QNRTPlayer 运行过程中的状态和事件回调
- (void)RTPlayer:(QNRTPlayer *)player didFailWithError:(NSError *)error;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| error | 错误内容 |
- (void)RTPlayer:(QNRTPlayer *)player playStateDidChange:(QNRTPlayState)playState;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| playState | playState 播放状态 |
- (void)RTPlayer:(QNRTPlayer *)player didGetStatistic:(NSDictionary *)statistic;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| statistic | 统计信息 ,包括:音频码率,视频码率,视频帧率 |
- (void)RTPlayer:(QNRTPlayer *)player trackDidReceived:(QNRTSourceKind )kind;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| kind | 数据类型 |
- (void)RTPlayer:(QNRTPlayer *)player firstSourceDidDecode:(QNRTSourceKind )kind;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| kind | 数据类型 |
- (void)RTPlayer:(QNRTPlayer *)player didStartPictureInPicture:(AVPictureInPictureController *)pictureInPictureController;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| pictureInPictureController | 画中画控制器 |
- (void)RTPlayer:(QNRTPlayer *)player didStopPictureInPicture:(AVPictureInPictureController *)pictureInPictureController;| 参数名 | 描述 |
|---|---|
| player | QNRTPlayer 实例 |
| pictureInPictureController | 画中画控制器 |
QNRTErrorDomain 定义了播放过程中的错误信息,包括但不限于连接错误、鉴权失败等错误信息。
| QNRTCErrorDomain | 错误码 | 功能 |
|---|---|---|
| QNRTErrorNetworkError | 20001 | 服务请求超时,或者域名解析错误等 |
| QNRTErrorAuthFailed | 20002 | 请求服务鉴权失败 |
| QNRTErrorPlayStreamNotExit | 20003 | 播放流地址不存在 |
| QNRTErrorPlayRequestFailed | 20004 | 对应服务 invalid parameter / server error |
| QNRTErrorDescriptionError | 20005 | 内部sdp错误 |
| QNRTErrorConnectFailed | 20006 | 连接异常 |
| QNRTErrorOperationNotAllowed | 20007 | 操作不被允许 |
QNRTPlayState 定义了播放的状态。
| QNRTPlayState | 功能 |
|---|---|
| QNRTPlayStateUnknow | 未知状态,只会作为 init 前的初始状态,开始播放之后任何情况下都不会再回到此状态 |
| QNRTPlayStateInit | 初始状态 |
| QNRTPlayStateReady | 准备播放的状态 |
| QNRTPlayStatePlaying | 正在播放的状态 |
| QNRTPlayStateStoped | 停止播放的状态 |
| QNRTPlayStateError | 播放发生错误的状态 |
QNRTSourceKind 定义了 source 的类型。
| QNRTSourceKind | 功能 |
|---|---|
| QNRTSourceKindAudio | 音频 |
| QNRTSourceKindVideo | 视频 |
QNRTVideoFillModeType 定义了视频填充模式。
| QNRTVideoFillModeType | 功能 |
|---|---|
| QNRTVideoFillModeStretch | 拉伸以填充整个视图 |
| QNRTVideoFillModePreserveAspectRatio | 画面均匀缩放的同时保持宽高比,添加指定背景色的条形 |
| QNRTVideoFillModePreserveAspectRatioAndFill | 保持源图像的长宽比,放大其中心以填充视图 |
QNScreenshotResultCallback 定义了截图的回调。
typedef void (^QNScreenshotResultCallback)(UIImage *ShotImage, NSError *error);这篇文档有帮助吗?
正在加载反馈服务…