帮助列表 |
@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