帮助列表
帮助列表
IOS_API

<<返回

VisSDK API For Objective-C 文档

当前SDK版本1.2.1

创建对象

@property (strong, nonatomic) VisSDK* visClient;
@property (weak, nonatomic) IBOutlet UIView *preview;
@property (weak, nonatomic) IBOutlet UIView *playView;
...
- (void) viewDidLoad {
    ...
    _visClient = [[VisSDK alloc] init];
}

设置

//设置参数
[_visClient setApp:@"..." andStream:@"..." andPassword:@"..." andUid:...];
//关联视图
_visClient.preview.frame = _preview.bounds;
_visClient.playView.frame = _playView.bounds;
[_preview addSubview:_visClient.preview];   //发布预览视图
[_playView addSubview:_visClient.playView]; //播放视图

获取上麦情况

[_visClient fetchMicState:^(int state) {
    //state的第0位代表第一个麦有是否上麦,第1位代表第二个麦是否上麦
    NSLog(@"%@",[NSString stringWithFormat:@"第1个麦:%d,第2个麦:%d",state&1,(state>>1)&1]);
} onError:^(int errCode, NSString *message) {
    if (errCode == kConnectionError) {
        //连接错误
        NSLog(@"%@",message);
    } else if(errCode == kPasswordError) {
        //密码错误
        NSLog(@"%@",message);
    } else {
        //请求错误 kRequestError
        NSLog(@"%@",message);
    }
}];

开始播放合成画面

//播放合成画面
[_visClient startPlay];

停止播放合成画面

//停止播放合成画面
[_visClient stopPlay];

开启预览

//发布直播前需要先开启预览,参数表示是否使用前置摄像头
[_visClient startPreviewWithCamera:NO];

停止预览

[_visClient stopPreview];

开始发布和播放

//发布直播,并播放另一端的画面
[_visClient startPlayAndPubOnSuccess:^{
    NSLog(@"publish success");
} onError:^(int errCode, NSString *message) {
    if (errCode == kConnectionError) {
        //http连接错误
        NSLog(@"%@",message);
    } else if (errCode == kPasswordError) {
        //密码错误
        NSLog(@"%@",message);
    } else if(errCode == kPublishConflict) {
        //发布冲突
        NSLog(@"%@",message);
    } else if (errCode == kRequestError) {
        //错误的内部http请求
        NSLog(@"%@",message);
    } else {
        //发布失败 kPublishFailed
        NSLog(@"%@",message);
    }
} withFlag:0];

停止发布和播放

//停止直播和播放
[_visClient stopPlayAndPubOnSuccess:^{
    NSLog(@"stoped publish");
}];

切换摄像头

//切换前后摄像头
[_visClient switchCamera];

麦克风打开和关闭

//参数micEnable为true表示打开麦克风,false表示关闭。默认打开
[_visClient setMicEnable:micEnable];

摄像头打开和关闭

//参数camEnable为true表示打开摄像头,false表示关闭。默认打开。
//该函数不影响预览,只影响发布输出
[_visClient setCamEnable:camEnable];

闪关灯开关

[_visClient setFlashEnable:flashEnable];

消除背景音效

//开启背景噪音消除,软件消除算法,有一定CPU消耗
[_visClient setDenoiseEnable:denoise];

释放资源

- (void) viewDidDisappear:(BOOL)animated {
    ...
    //会停止播放和发布、关闭预览
    [_visClient shutdown];
}

Edit By MaHua



<<返回


2006 - 2023 aodianyun.com, All Rights Reserved. 奥点科技 版权所有 增值电信业务经营许可证:浙B2-20110306 浙ICP备07500424号 |

  • 电话

    X

    售前咨询:

    400-663-6063

    售后服务:

    400-663-6063

  • 客服

  • 建议

    咨询留言 X
    提  交

在线QQ

售前咨询400-663-6063

售后服务400-663-6063