前言
- 声网Agora是最近类似七牛云和腾讯云的直播视频类的付费SDK,官网上的Demo不是很易懂,所以下面举个例子。
开发准备
- podfile导入
pod 'AgoraRtcEngine_iOS'
代码
#import "ViewController.h"
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
@interface ViewController () <AgoraRtcEngineDelegate>
@property(nonatomic, strong) AgoraRtcEngineKit *agoraKit;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.agoraKit startPreview];
}
#pragma mark - agoraKit
- (AgoraRtcEngineKit *)agoraKit {
if(_agoraKit == nil) {
_agoraKit = [AgoraRtcEngineKit sharedEngineWithAppId:@"your key" delegate:self];
[_agoraKit enableVideo];
AgoraRtcVideoCanvas *videoCanvas = [[AgoraRtcVideoCanvas alloc] init];
videoCanvas.view = self.view;
videoCanvas.renderMode = AgoraVideoRenderModeHidden;
[_agoraKit setupLocalVideo:videoCanvas];
}
return _agoraKit;
}
- (void)setCameraFront {
AgoraCameraCapturerConfiguration *configuration = [[AgoraCameraCapturerConfiguration alloc]init];
configuration.cameraDirection = AgoraCameraDirectionFront;
[self.agoraKit setCameraCapturerConfiguration:configuration];
}
@end
关于其他详细的文档
- 官网文档
- 我方和对方第一帧画面的回调
- 声音静音的回调
- 开始视频的方法等