首页
产品
帮助文档
博客
控制台

接入步骤

目录

  1. 环境需求

  2. 添加SDK

  3. 初始化

  4. 加入房间

  5. 离开房间

  6. Demo下载

环境需求

添加SDK

初始化

使用目睹云的互动直播主机地址、推流配置和渲染的view来创建MRTCInteractiveClient实例

#import <MRTC_Interactive/MRTC_Interactive.h>
...

- (void)initClient {
    MRTCSetting *defaultSetting = [[MRTCSetting alloc]init];
    self.mrtcClient = [[MRTCInteractiveClient alloc]initWithHost:@"interactive.myun.tv" setting:defaultSetting renderer:self.rendererView];
}

加入频道

在初始化MRTCInteractiveClient实例之后,调用joinWithChannel: role: password: delegate:方法加入频道

   //channel:频道id
   //role:角色 主播为main,嘉宾为1起始的数字字符
   //password:密码 主播和嘉宾的密码是不同的
   //delegate:代理
   - (void)joinRoom {
      [self.mrtcClient joinWithChannel:@"channelId" role:@"main" password:@"xxxxxxxx" delegate:self];
   }

   //加入房间的代理方法MRTCInteractiveClientRoomDelegate
   - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client joinSuccess:(NSArray<NSString *> *)roleArray{
      //加入成功
      //roleArray为房间中当前在线的其他角色,可以调用playRoleWithRole:来进行播放
   }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client joinFailed:(MRTCError *)error{
     //加入失败
  }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client onJoinRoles:(NSArray<NSString *> *)roleArray{
     //新加入房间的角色数组,可以调用playRoleWithRole:来进行播放
  }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client onLeaveRoles:(NSArray<NSString *> *)roleArray{
     //离开房间的角色数组
  }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client playRoleSuccess:(NSString *)role{
     //播放角色成功
  }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client playRole:(NSString *)role failure:(MRTCError *)error{
     //播放角色失败
  }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client stateChanged:(MRTCInteractiveClientState)state{
     //连接状态改变回调
  }

  - (void)MRTCInteractiveClient:(MRTCInteractiveClient *)client onError:(MRTCError *)error{
     //其他错误回调
  }

离开频道

调用leave方法离开频道,调用该方法会把直播相关的资源释放

- (void)leaveChanel {
   [self.mrtcClient leave];
}

iOS demo 下载