iOS开发-声网Agora Demo

前言

  • 声网Agora是最近类似七牛云和腾讯云的直播视频类的付费SDK,官网上的Demo不是很易懂,所以下面举个例子。

开发准备

  • podfile导入
    pod 'AgoraRtcEngine_iOS'

代码

  • ViewController.m
#import "ViewController.h"
#import <AgoraRtcKit/AgoraRtcEngineKit.h> //声网SDK

@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

关于其他详细的文档

  • 官网文档
    • 我方和对方第一帧画面的回调
    • 声音静音的回调
    • 开始视频的方法等

猜你喜欢

转载自blog.csdn.net/weixin_41732253/article/details/110287622