### Local Development Commands Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Web/README.md Commands to install dependencies and start the development server. ```bash // 安装 npm 包(安装速度慢) npm install // 若已安装 cnpm 、pnpm、tnpm 等工具,请使用选择以下某个指令安装 cnpm install pnpm install tnpm install // 安装完成后,执行 dev 指令,运行成功后根据提示使用浏览器访问即可 npm run dev ``` -------------------------------- ### Start Live Streaming Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Starts the live streaming process. Can be initiated without a specific URL, or with a provided push URL. Includes callbacks for success and errors. ```java import com.aliyun.auipusher.LivePusherService; import com.alivc.auicommon.common.base.exposable.Callback; import android.view.View; // 开始直播推流 pusherService.startLive(new Callback() { @Override public void onSuccess(View view) { Log.d("Pusher", "推流开始"); } @Override public void onError(String errorMsg) { Log.e("Pusher", "推流失败: " + errorMsg); } }); // 指定推流URL开始直播 String pushUrl = "rtmp://push.example.com/live/stream_001?auth_key=xxx"; pusherService.startLive(pushUrl, new Callback() { @Override public void onSuccess(View view) { Log.d("Pusher", "推流开始"); } @Override public void onError(String errorMsg) { Log.e("Pusher", "推流失败: " + errorMsg); } }); ``` -------------------------------- ### Start Live Preview Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Initiates the live preview stream and provides a View to be added to the layout for displaying the preview. Handles success and error callbacks. ```java import com.aliyun.auipusher.LivePusherService; import com.alivc.auicommon.common.base.exposable.Callback; import android.view.View; // 开始预览 pusherService.startPreview(new Callback() { @Override public void onSuccess(View previewView) { // 将预览视图添加到布局 previewContainer.addView(previewView); Log.d("Pusher", "预览开始"); } @Override public void onError(String errorMsg) { Log.e("Pusher", "预览失败: " + errorMsg); } }); ``` -------------------------------- ### Initialize Beauty UI Panel Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIBeauty/README.md Programmatic setup for the beauty menu panel within the activity or fragment. ```java QueenMenuPanel beautyMenuPanel = QueenBeautyMenu.getPanel(context); beautyMenuPanel.onHideMenu(); beautyMenuPanel.onHideValidFeatures(); beautyMenuPanel.onHideCopyright(); QueenBeautyMenu beautyBeautyContainerView = findViewById(R.id.beauty_beauty_menuPanel); beautyBeautyContainerView.addView(beautyMenuPanel); ``` -------------------------------- ### Build and Deploy Service Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Commands to package the application using Maven, start the JAR file with a custom port, and verify the deployment via curl. ```bash # 打包并启动服务 mvn package -DskipTests java -Dserver.port=9000 -jar target/webframework.jar # 验证部署 curl http://localhost:9000/ # 返回: {"code":200,"msg":"部署成功,可正常访问地址 http://localhost"} ``` -------------------------------- ### iOS SDK Host Starts Basic Live Stream Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Create a basic live stream room. This function requires the current view controller and provides a callback with the live room information upon successful creation. ```objc #import "AUIInteractionLiveManager.h" // 基础直播模式开播 - (void)startBasicLive { [[AUIInteractionLiveManager defaultManager] createLive:AUIRoomLiveModeBase title:@"我的直播间" notice:@"欢迎来到直播间" currentVC:self completed:^(BOOL success, AUIRoomLiveInfoModel *model) { if (success) { NSLog(@"直播间创建成功,ID: %@", model.live_id); } else { NSLog(@"直播间创建失败"); } }]; } ``` -------------------------------- ### Get Live Room Details Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Fetch comprehensive information for a specific live room using its unique ID. ```bash # 获取直播间详情 curl -X POST "https://your-appserver-domain/api/v1/live/get" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "user_id": "user_001", "id": "live_room_001", "im_server": ["aliyun_new_im"] }' # 返回结果 { "code": 200, "id": "live_room_001", "title": "直播间标题", "status": 1, "mode": 1, "anchor_id": "anchor_001", "chat_id": "chat_group_001", "pull_url_info": { "rtmp_url": "rtmp://pull.example.com/live/stream_001", "flv_url": "https://pull.example.com/live/stream_001.flv" } } ``` -------------------------------- ### AUIMessage API Call Examples Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/AUIBaseKits/AUIMessage/README.md Demonstrates common API calls for AUIMessage, including adding listeners, configuration, login, joining/leaving groups, and sending messages. ```objective-c // 添加Listener [[[AUIMessageServiceFactory getMessageService] getListenerObserver] addListener:self]; ``` ```objective-c // 配置 AUIMessageConfig *config = [AUIMessageConfig new]; config.tokenData = data; // 具体的kv值,可以参考实现 [[AUIMessageServiceFactory getMessageService] setConfig:config]; ``` ```objective-c // 登录 AUIMessageUserInfo *userInfo = [AUIMessageUserInfo new]; userInfo.userId = @"uid"; userInfo.userNick = @"昵称"; userInfo.userAvatar = @"http://xxxx.png"; [[AUIMessageServiceFactory getMessageService] login:userInfo callback:^(NSError *error) { if (error) { // 失败 } else { // 成功 } }]; ``` ```objective-c // 入群 AUIMessageJoinGroupRequest *req = [AUIMessageJoinGroupRequest new]; req.groupId = groupID; [self.messageService joinGroup:req callback:^(NSError * _Nullable error) { if (error) { // 失败 } else { // 成功 } }]; ``` ```objective-c // 离群 AUIMessageLeaveGroupRequest *req = [AUIMessageLeaveGroupRequest new]; req.groupId = groupID; [self.messageService leaveGroup:req callback:^(NSError * _Nullable error) { if (error) { // 失败 } else { // 成功 } }]; ``` ```objective-c // 单发消息 AUIMessageSendMessageToGroupUserRequest *req = [AUIMessageSendMessageToGroupUserRequest new]; req.groupId = groupID; req.data = data; req.msgType = type; req.receiverId = receiverId; [self.messageService sendMessageToGroupUser:req callback:^(AUIMessageSendMessageToGroupUserResponse * _Nullable rsp, NSError * _Nullable error) { if (error) { // 失败 } else { // 成功 } }]; ``` ```objective-c // 群发消息 AUIMessageSendMessageToGroupRequest *req = [AUIMessageSendMessageToGroupRequest new]; req.groupId = groupID; req.data = data; req.msgType = type; req.skipAudit = YES; req.skipMuteCheck = YES; [self.messageService sendMessageToGroup:req callback:^(AUIMessageSendMessageToGroupResponse * _Nullable rsp, NSError * _Nullable error) { if (error) { // 失败 } else { // 成功 } }]; ``` -------------------------------- ### iOS SDK User Login Setup Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Set the current logged-in user information before entering a live room. This involves creating an AUIRoomAccount object and populating it with user details and authentication token. ```objc #import "AUIInteractionLiveManager.h" #import "AUIRoomAccount.h" // 登录后设置用户信息 - (void)setupUserAccount { AUIRoomAccount *account = [AUIRoomAccount new]; account.myInfo.userId = @"user_001"; account.myInfo.avatar = @"https://example.com/avatar.png"; account.myInfo.nickName = @"用户昵称"; account.myToken = @"jwt_token_from_login"; [[AUIInteractionLiveManager defaultManager] setMyAccount:account]; } ``` -------------------------------- ### Control Live Room Status Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Manage the lifecycle of a live room by starting, pausing, stopping, or deleting it. ```bash # 开始直播 curl -X POST "https://your-appserver-domain/api/v1/live/start" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{"id": "live_room_001", "user_id": "anchor_001"}' # 暂停直播 curl -X POST "https://your-appserver-domain/api/v1/live/pause" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{"id": "live_room_001", "user_id": "anchor_001"}' # 停止直播 curl -X POST "https://your-appserver-domain/api/v1/live/stop" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{"id": "live_room_001", "user_id": "anchor_001"}' # 删除直播间 curl -X POST "https://your-appserver-domain/api/v1/live/delete" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{"id": "live_room_001", "user_id": "anchor_001"}' ``` -------------------------------- ### Create Live Stream (LinkMic Mode) Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md Start a live stream with link mic functionality enabled. Specify the title, notice, and the current view controller. The completion handler is optional. ```Objective-C // 主播开播(连麦模式) [[AUIInteractionLiveManager defaultManager] createLive:AUIRoomLiveModeLinkMic title:@"直播间标题" notice:@"这是一个公告" currentVC:self completed:nil]; ``` -------------------------------- ### Android SDK Application Initialization Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Initialize the AUIInteractionLiveManager in your Application class. This includes setting the integration way, configuring the AppServer URL, and calling the setup method. ```java // Application.java - 初始化调用 import com.aliyun.auiinteractionlive.AUIInteractionLiveManager; public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); // 注册项目类型 AlivcBase.setIntegrationWay("aui-live-interaction"); // 配置AppServer地址 RetrofitManager.setAppServerUrl("https://your-appserver-domain"); // 初始化 AUIInteractionLiveManager.setup(this); } } ``` -------------------------------- ### Configure AUIMessageConfig for AliVCIMCompat Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/AUIBaseKits/AUIMessage/README.md Configure the AUIMessageConfig with token data, specifying the SDK mode ('aliyun_new' or 'aliyun_old') based on your integration needs. This setup is for the AliVCIMCompat implementation. ```objective-c NSMutableDictionary *data = [NSMutableDictionary new]; [data setObject:_useAlivc ? @"aliyun_new" : @"aliyun_old" forKey:@"mode"]; [data setObject:@"xxx" forKey:@"xxx"]; // 设置token字段,具体参考对应的impl实现 AUIMessageConfig *config = [AUIMessageConfig new]; config.tokenData = data; [[AUIMessageServiceFactory getMessageService] setConfig:config]; ``` -------------------------------- ### iOS SDK Host Starts Link Mic Live Stream Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Create a live stream room that supports audience link mic. This function requires the current view controller and provides a callback with the live room information upon successful creation. ```objc #import "AUIInteractionLiveManager.h" // 连麦互动模式开播 - (void)startLinkMicLive { [[AUIInteractionLiveManager defaultManager] createLive:AUIRoomLiveModeLinkMic title:@"连麦直播间" notice:@"支持观众连麦互动" currentVC:self completed:^(BOOL success, AUIRoomLiveInfoModel *model) { if (success) { NSLog(@"连麦直播间创建成功"); } }]; } ``` -------------------------------- ### iOS SDK Initialization and Configuration Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Initialize the SDK and set up the AppServer address during application launch. Ensure the AUIInteractionLiveManager is set up before proceeding with other functionalities. ```objc // AppDelegate.m - 应用启动初始化 #import "AUIInteractionLiveManager.h" - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 初始化SDK配置 [[AUIInteractionLiveManager defaultManager] setup]; // 设置首页为直播列表页 AUIHomeViewController *homeVC = [AUIHomeViewController new]; // 使用AVNavigationController作为导航控制器 AVNavigationController *nav = [[AVNavigationController alloc] initWithRootViewController:homeVC]; [self.window setRootViewController:nav]; [self.window makeKeyAndVisible]; return YES; } // AUIInteractionLiveManager.m - 修改AppServer域名 static NSString * const kLiveServiceDomainString = @"https://your-appserver-domain"; ``` -------------------------------- ### Package and Launch Application (Shell) Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Server/Java/README.md This shell script demonstrates how to package the Java application using Maven and then launch it. It skips tests during packaging and renames the JAR file before execution. The application is configured to listen on port 9000. ```shell #!/usr/bin/env bash mvn package -DskipTests cp target/*.jar target/webframework.jar java -Dserver.port=9000 -jar target/webframework.jar ``` -------------------------------- ### Build Project Command Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Web/README.md Command to build the project for production. ```bash // 运行 build 指令即可构建最终产物至 ./dist 目录下 npm run build ``` -------------------------------- ### Initialize SDK in Application Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md Initialize the AUIInteractionLiveManager SDK during application launch. Ensure necessary headers are imported and a navigation controller (preferably AVNavigationController) is set up for inter-page navigation. ```Objective-C #import "AUIInteractionLiveManager.h" - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // 在这里进行初始化,注意需要引入头文件 [[AUIInteractionLiveManager defaultManager] setup]; // APP首页 AUIHomeViewController *liveVC = [AUIHomeViewController new]; // 需要使用导航控制器,否则页面间无法跳转,建议AVNavigationController // 如果使用系统UINavigationController作为APP导航控制器,需要你进行以下处理: // 1、隐藏导航控制器的导航栏:self.navigationBar.hidden = YES // 2、直播间(AUILiveRoomAnchorViewController和AUILiveRoomAudienceViewController)禁止使用向右滑动时关闭直播间操作。 AVNavigationController *nav =[[AVNavigationController alloc]initWithRootViewController:liveVC]; [self.window setRootViewController:nav]; [self.window makeKeyAndVisible]; // 你的其他初始化... return YES; } ``` -------------------------------- ### POST /api/v1/live/create Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Creates a new live streaming room and returns the push/pull stream URLs. ```APIDOC ## POST /api/v1/live/create ### Description Creates a new live streaming room and returns the push/pull stream URLs. ### Method POST ### Endpoint https://your-appserver-domain/api/v1/live/create ### Request Body - **anchor_id** (string) - Required - Anchor user ID - **anchor_nick** (string) - Required - Anchor nickname - **title** (string) - Required - Room title - **notice** (string) - Optional - Room notice - **mode** (integer) - Required - 0: Basic, 1: Co-hosting - **im_server** (array) - Required - IM server list ### Request Example { "anchor_id": "anchor_001", "anchor_nick": "主播昵称", "title": "直播间标题", "notice": "直播间公告", "mode": 1, "im_server": ["aliyun_new_im"] } ### Response #### Success Response (200) - **id** (string) - Room ID - **push_url** (string) - RTMP push URL - **pull_url_info** (object) - Pull URLs for RTMP, FLV, HLS #### Response Example { "code": 200, "id": "live_room_001", "push_url": "rtmp://push.example.com/...", "pull_url_info": { "rtmp_url": "...", "flv_url": "...", "hls_url": "..." } } ``` -------------------------------- ### Create Live Room Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Initialize a new live room and receive the associated room information along with push/pull stream URLs. ```bash # 创建直播间 curl -X POST "https://your-appserver-domain/api/v1/live/create" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "anchor_id": "anchor_001", "anchor_nick": "主播昵称", "title": "直播间标题", "notice": "直播间公告", "mode": 1, "im_server": ["aliyun_new_im"] }' # mode说明: 0=基础直播模式, 1=连麦互动模式 # 返回结果 { "code": 200, "id": "live_room_001", "title": "直播间标题", "status": 0, "mode": 1, "push_url": "rtmp://push.example.com/live/stream_001?auth_key=xxx", "pull_url_info": { "rtmp_url": "rtmp://pull.example.com/live/stream_001", "flv_url": "https://pull.example.com/live/stream_001.flv", "hls_url": "https://pull.example.com/live/stream_001.m3u8" } } ``` -------------------------------- ### Message Service Instantiation via Reflection Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIMessage/README.md Demonstrates how the MessageService instance is created using reflection. This allows for dynamic loading of different IM SDK implementations. ```java messageService = (MessageService) implType.newInstance(); ``` -------------------------------- ### Add Maven Repository for Aliyun SDKs Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/README.md Include the Aliyun Maven repository to access SDKs. This is typically added to your project-level build.gradle file. ```groovy maven { url 'https://maven.aliyun.com/nexus/content/repositories/releases' } ``` -------------------------------- ### Add Gradle Dependencies for Interactive Live SDK Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/README.md Include the necessary SDKs for interactive live streaming. Use the latest versions available and refer to the official documentation for updates. ```groovy // 互动信令SDK implementation "com.aliyun.sdk.android:AliVCInteractionMessage:${latest_version}" // 一体化SDK(请参考 AndroidThirdParty 目录下的 config.gradle 文件,获取 externalAllInOne 最新版本) // 建议使用最新版本,详情参考官网:https://help.aliyun.com/zh/apsara-video-sdk/download-sdks implementation "com.aliyun.aio:AliVCSDK_InteractiveLive:${latest_version}" ``` -------------------------------- ### Initialize LivePusherService Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Obtains an instance of the LivePusherService. This service controls live streaming functionalities like preview and push. ```java import com.aliyun.auipusher.LivePusherService; import com.alivc.auicommon.common.base.exposable.Callback; import android.view.View; // 获取推流服务实例 LivePusherService pusherService = LiveServiceImpl.getInstance().getPusherService(); ``` -------------------------------- ### Create Live Stream (Base Mode) Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md Initiate a live stream using the base mode. Provide a title, notice, and the current view controller. The 'completed' block can handle post-creation logic. ```Objective-C // 主播开播(基础模式) [[AUIInteractionLiveManager defaultManager] createLive:AUIRoomLiveModeBase title:@"直播间标题" notice:@"这是一个公告" currentVC:self completed:nil]; ``` -------------------------------- ### 查看 iOS 源码目录结构 Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md 展示了 AUIInteractionLive iOS 平台的项目文件布局。 ```text ├── iOS // iOS平台的根目录 │ ├── AUIInteractionLive.podspec // pod描述文件 │ ├── Source // 源代码文件 │ ├── Resources // 资源文件 │ ├── Example // Demo代码 │ ├── AUIBaseKits // 基础UI组件 │ ├── README.md // Readme ``` -------------------------------- ### Web SDK Service Layer Implementation Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Demonstrates how to use the service layer for authentication, token retrieval, and room data management in a TypeScript environment. ```typescript // src/services/index.ts - 服务类使用示例 import services from '@/services'; // 检查登录状态 async function checkLoginStatus() { try { const userInfo = await services.checkLogin(); console.log('已登录用户:', userInfo.userName); return true; } catch (error) { console.log('未登录,跳转到登录页'); return false; } } // 用户登录 async function login(userId: string, username: string) { try { const result = await services.login(userId, username); console.log('登录成功,token:', result.token); return result; } catch (error) { console.error('登录失败:', error); throw error; } } // 获取IM Token async function getIMToken() { try { const tokenResult = await services.getToken(['aliyun_new_im'], 'audience'); console.log('IM Token获取成功'); return tokenResult.aliyunIMV2; } catch (error) { console.error('获取IM Token失败:', error); throw error; } } // 获取直播间列表 async function fetchRoomList(page: number = 1) { try { const list = await services.getRoomList(page, 20, ['aliyun_new_im']); console.log('获取到直播间数量:', list.length); return list; } catch (error) { console.error('获取列表失败:', error); throw error; } } // 获取直播间详情 async function fetchRoomDetail(roomId: string) { try { const detail = await services.getRoomDetail(roomId, ['aliyun_new_im']); console.log('直播间信息:', detail.title, '状态:', detail.status); return detail; } catch (error) { console.error('获取详情失败:', error); throw error; } } // 获取用户信息 function getCurrentUser() { const userInfo = services.getUserInfo(); return { userId: userInfo.userId, userNick: userInfo.userNick, userAvatar: userInfo.userAvatar, }; } ``` -------------------------------- ### Initialize and Login to MessageService Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Initializes the MessageService using a factory method and logs in a user with their profile information. Requires specifying the IM service implementation type. ```java import com.alivc.auimessage.MessageService; import com.alivc.auimessage.MessageServiceFactory; import com.alivc.auimessage.AUIMessageServiceImplType; import com.alivc.auimessage.model.base.AUIMessageUserInfo; import com.alivc.auimessage.listener.InteractionCallback; // 创建消息服务实例 MessageService messageService = MessageServiceFactory.getMessageService( AUIMessageServiceImplType.ALIVC_IM // 使用阿里云新版IM SDK ); // 登录消息服务 AUIMessageUserInfo userInfo = new AUIMessageUserInfo(); userInfo.userId = "user_001"; userInfo.userNick = "用户昵称"; userInfo.userAvatar = "https://example.com/avatar.png"; messageService.login(userInfo, new InteractionCallback() { @Override public void onSuccess(Void data) { Log.d("IM", "登录成功"); } @Override public void onError(String errorMsg) { Log.e("IM", "登录失败: " + errorMsg); } }); ``` -------------------------------- ### Project Configuration (YAML) Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Server/Java/README.md This YAML configuration file defines server port, database connection details, Jackson settings, Mybatis-plus configurations, and various business-specific settings for OpenAPI, IM, live streaming, and callbacks. Ensure sensitive information like database credentials and API keys are kept secure. ```yaml server: port: 8080 spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver url: jdbc:mysql://*****:3306/****?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai username: r***** password: p***** jackson: time-zone: GMT+8 date-format: yyyy-MM-dd'T'HH:mm:ss default-property-inclusion: non_null mybatis-plus: typeAliasesPackage: com.aliyuncs.aui.entity configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl default-statement-timeout: 10 biz: openapi: access: key: daeewe***** secret: we2wewe****** region_id: cn-shanghai live_im: app_id: TY3**** live_stream: push_url: push.*****.vip pull_url: pull.*****.vip push_auth_key: zJl4****** pull_auth_key: mDZs******** app_name: live auth_expires: 604800 live_mic: app_id: 7c61******** app_key: c461b********* new_im: appId: "0c8xxxxx" appKey: "586fxxxxxx" appSign: "232sfxxxxxx" live_callback: auth_key: avdsd******* http: cors: host: "*" ``` -------------------------------- ### Configure application.yml Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Defines server, database, OpenAPI, IM, live streaming, and CORS settings for the application. ```yaml server: port: 8080 spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/aui_live?useUnicode=true&characterEncoding=UTF-8 username: root password: your_password biz: # 阿里云OpenAPI配置 openapi: access: key: your_access_key secret: your_access_secret region_id: cn-shanghai # IM服务配置 new_im: appId: "your_im_app_id" appKey: "your_im_app_key" appSign: "your_im_app_sign" # 直播推拉流配置 live_stream: push_url: push.example.com pull_url: pull.example.com push_auth_key: your_push_auth_key pull_auth_key: your_pull_auth_key app_name: live auth_expires: 604800 # 连麦应用配置 live_mic: app_id: your_rtc_app_id app_key: your_rtc_app_key # 跨域配置 http: cors: host: "*" ``` -------------------------------- ### Join and Send Messages in a Group Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Demonstrates how to join a specified group (e.g., a live chat room) and send custom messages to that group. Requires group ID and message details. ```java import com.alivc.auimessage.MessageService; import com.alivc.auimessage.model.request.JoinGroupRequest; import com.alivc.auimessage.model.response.JoinGroupResponse; import com.alivc.auimessage.model.request.SendMessageToGroupRequest; import com.alivc.auimessage.model.response.SendMessageToGroupResponse; import com.alivc.auimessage.listener.InteractionCallback; // 加入群组(直播间聊天室) JoinGroupRequest joinRequest = new JoinGroupRequest(); joinRequest.groupId = "chat_group_001"; messageService.joinGroup(joinRequest, new InteractionCallback() { @Override public void onSuccess(JoinGroupResponse response) { Log.d("IM", "加入群组成功,当前在线人数: " + response.onlineCount); } @Override public void onError(String errorMsg) { Log.e("IM", "加入群组失败: " + errorMsg); } }); // 发送群组消息 SendMessageToGroupRequest msgRequest = new SendMessageToGroupRequest(); msgRequest.groupId = "chat_group_001"; msgRequest.msgType = 10001; // 自定义消息类型 msgRequest.data = "{\"content\":\"大家好!\"}"; messageService.sendMessageToGroup(msgRequest, new InteractionCallback() { @Override public void onSuccess(SendMessageToGroupResponse response) { Log.d("IM", "消息发送成功,messageId: " + response.messageId); } @Override public void onError(String errorMsg) { Log.e("IM", "消息发送失败: " + errorMsg); } }); ``` -------------------------------- ### 配置 Podfile 集成互动直播组件 Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md 通过 CocoaPods 引入音视频终端 SDK 及相关 AUI 组件,需确保 iOS 版本要求及路径配置正确。 ```ruby #需要iOS10.0及以上才能支持 platform :ios, '10.0' target '你的App target' do # 根据自己的业务场景,集成合适的音视频终端SDK # 如果你的APP中还需要频短视频编辑功能,可以使用音视频终端全功能SDK(AliVCSDK_Standard),可以把本文件中的所有AliVCSDK_InteractiveLive替换为AliVCSDK_Standard pod 'AliVCSDK_InteractiveLive', '~> 6.14.0' # 基础UI组件 pod 'AUIFoundation/All', :path => "./AUIInteractionLive/AUIBaseKits/AUIFoundation/" # 互动消息组件 pod 'AUIMessage/AliVCIM', :path => "./AUIInteractionLive/AUIBaseKits/AUIMessage/" # 美颜UI组件,有三种选择形式 # 1、如果终端SDK使用的是AliVCSDK_Standard,需要“AliVCSDK_InteractiveLive”替换为“AliVCSDK_Standard” # 2、如果需要使用专业版Queen,需要把“AliVCSDK_InteractiveLive”替换为“Queen” # 3、如果无需美颜,则无需集成AUIBeauty pod 'AUIBeauty/AliVCSDK_InteractiveLive', :path => "./AUIInteractionLive/AUIBaseKits/AUIBeauty/" # 互动直播竖屏样式UI组件,如果终端SDK使用的是AliVCSDK_Standard,需要AliVCSDK_InteractiveLive替换为AliVCSDK_Standard pod 'AUIInteractionLive/AliVCSDK_InteractiveLive', :path => "./AUIInteractionLive/" end ``` -------------------------------- ### Android SDK Manifest Configuration Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Configure the License Key in the AndroidManifest.xml file and declare necessary permissions for internet, camera, audio recording, and network state access. ```xml ``` -------------------------------- ### Initialize Current User Account Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md After user login, initialize the current user's account details with the AUIInteractionLiveManager. This is crucial for enabling and viewing live streams. Ensure user tokens are valid. ```Objective-C // 在登录后进行,进行赋值 // 如果本次启动用户不需要重新登录(用户token未过期),可以在加载登录用户后进行赋值 AUIRoomAccount *account = [AUIRoomAccount new]; account.myInfo.userId = @"当前登录用户id"; account.myInfo.avatar = @"当前登录用户头像"; account.myInfo.nickName = @"当前登录用户昵称"; account.myToken = @"当前登录用户token"; // 用于服务端用户有效性验证 [[AUIInteractionLiveManager defaultManager] setMyAccount:account]; ``` -------------------------------- ### Configure Beauty UI Layout Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIBeauty/README.md XML layout definition for the QueenBeautyMenu component. ```xml ``` -------------------------------- ### Proguard Rules for Aliyun SDKs Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/README.md Add these Proguard rules to your app's Proguard configuration file to prevent code stripping and ensure proper functioning of the Aliyun SDKs. ```text -keep class com.alivc.** { *; } -keep class com.aliyun.** { *; } -keep class com.aliyun.rts.network.* { *; } -keep class org.webrtc.** { *; } -keep class com.alibaba.dingpaas.** { *; } -keep class com.dingtalk.mars.** { *; } -keep class com.dingtalk.bifrost.** { *; } -keep class com.dingtalk.mobile.** { *; } -keep class org.android.spdy.** { *; } -keep class com.alibaba.dingpaas.interaction.** { *; } -keep class com.cicada.**{*;} ``` -------------------------------- ### List Live Rooms Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Retrieve a paginated list of live rooms, with options to filter by active status. ```bash # 获取直播间列表 curl -X POST "https://your-appserver-domain/api/v1/live/list" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "user_id": "user_001", "page_num": 1, "page_size": 20, "im_server": ["aliyun_new_im"] }' # 返回结果 (数组) [ { "id": "live_room_001", "title": "直播间标题", "anchor_id": "anchor_001", "anchor_nick": "主播昵称", "status": 1, "mode": 0, "online_count": 1234, "created_at": "2024-01-01T10:00:00" } ] ``` -------------------------------- ### POST /api/v1/live/login Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Authenticates a user and returns a JWT token for subsequent API requests. ```APIDOC ## POST /api/v1/live/login ### Description Authenticates a user and returns a JWT token for subsequent API requests. ### Method POST ### Endpoint https://your-appserver-domain/api/v1/live/login ### Request Body - **username** (string) - Required - User identifier - **password** (string) - Required - User password ### Request Example { "username": "test_user", "password": "test_user" } ### Response #### Success Response (200) - **code** (integer) - Status code - **token** (string) - JWT authentication token - **expire** (string) - Token expiration timestamp #### Response Example { "code": 200, "token": "eyJhbGciOiJIUzI1NiJ9...", "expire": "2024-12-31T23:59:59" } ``` -------------------------------- ### Define Beauty Implementation Class Name Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIBeauty/README.md Constant definition for the reflection-based instantiation of the beauty manager. Ensure the package name matches the actual implementation class to avoid initialization failures. ```java public class BeautyConstant { // 由于beauty模块是插件化,因此beauty实例是通过反射进行实例化,请注意修改美颜具体实现(impl)类名,以免出现美颜初始化失败导致美颜失效的问题 public static final String BEAUTY_QUEEN_MANAGER_CLASS_NAME = "com.alivc.auibeauty.queenbeauty.QueenBeautyImpl"; } ``` -------------------------------- ### Manage Meeting Information Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Retrieve or update participant information for multi-user co-hosting scenarios. ```bash # 获取连麦用户信息 curl -X POST "https://your-appserver-domain/api/v1/live/getMeetingInfo" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{"id": "live_room_001"}' # 更新连麦用户信息 curl -X POST "https://your-appserver-domain/api/v1/live/updateMeetingInfo" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "id": "live_room_001", "members": [ {"user_id": "user_001", "user_nick": "观众1", "camera_opened": true, "mic_opened": true}, {"user_id": "user_002", "user_nick": "观众2", "camera_opened": true, "mic_opened": false} ] }' ``` -------------------------------- ### Configure License Key in AndroidManifest.xml Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/README.md Add your license key to the AndroidManifest.xml file. Ensure the 'tools:node="replace"' attribute is present to override any existing values. ```xml ``` -------------------------------- ### iOS SDK Audience Joins Live Room with Model Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Enable viewers to join a live room using a live room information model. This function requires the current view controller and provides a callback indicating success or failure. ```objc #import "AUIInteractionLiveManager.h" // 通过直播间模型进入 - (void)joinLiveRoomWithModel:(AUIRoomLiveInfoModel *)model { [[AUIInteractionLiveManager defaultManager] joinLive:model currentVC:self completed:^(BOOL success) { if (success) { NSLog(@"成功进入直播间"); } }]; } ``` -------------------------------- ### Android SDK Gradle Dependencies Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Configure Maven repositories and add dependencies for the AliVCInteractionMessage and AliVCSDK_InteractiveLive libraries in your app's build.gradle file. ```groovy // build.gradle - Maven仓库配置 repositories { maven { url 'https://maven.aliyun.com/nexus/content/repositories/releases' } } dependencies { // 互动信令SDK implementation "com.aliyun.sdk.android:AliVCInteractionMessage:1.3.1" // 一体化SDK(互动直播) implementation "com.aliyun.aio:AliVCSDK_InteractiveLive:6.14.0" } ``` -------------------------------- ### Implement Beauty Processing Logic Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIBeauty/README.md Integration of beauty processing within the AlivcLivePushCustomFilter lifecycle methods. ```java private BeautyInterface mBeautyManager; mALivcLivePusher.setCustomFilter(new AlivcLivePushCustomFilter() { @Override public void customFilterCreate() { initBeautyManager(); } @Override public int customFilterProcess(int inputTexture, int textureWidth, int textureHeight, long extra) { if (mBeautyManager == null) { return inputTexture; } return mBeautyManager.onTextureInput(inputTexture, textureWidth, textureHeight); } @Override public void customFilterDestroy() { destroyBeautyManager(); Log.d(TAG, "customFilterDestroy---> thread_id: " + Thread.currentThread().getId()); } }); private void initBeautyManager() { if (mBeautyManager == null) { Log.d(TAG, "initBeautyManager start"); // 从v6.2.0开始,基础模式下的美颜,和互动模式下的美颜,处理逻辑保持一致,即:QueenBeautyImpl; mBeautyManager = BeautyFactory.createBeauty(BeautySDKType.QUEEN, mContext); // initialize in texture thread. mBeautyManager.init(); mBeautyManager.setBeautyEnable(isBeautyEnable); mBeautyManager.switchCameraId(mCameraId); Log.d(TAG, "initBeautyManager end"); } } private void destroyBeautyManager() { if (mBeautyManager != null) { mBeautyManager.release(); mBeautyManager = null; } } ``` -------------------------------- ### Define Module Dependencies Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIBeauty/README.md Full dependency configuration for the AUIBeauty module, including UI components and the Interactive Live SDK. ```groovy dependencies { api project(':AUIBaseKits:AUIBeauty:live_beauty') // 美颜UI面板(请参考 AndroidThirdParty 目录下的 config.gradle 文件,获取 externalAliyunQueenUI 最新版本) api "com.aliyun.maliang.android:queen_menu:${latest_version}" // 一体化SDK,包含基础美颜功能(请参考 AndroidThirdParty 目录下的 config.gradle 文件,获取 externalAllInOne 最新版本) implementation "com.aliyun.aio:AliVCSDK_InteractiveLive:${latest_version}" // 此处引用外部独立版本高级功能Queen(请参考 AndroidThirdParty 目录下的 config.gradle 文件,获取 externalAliyunQueen 最新版本) implementation "com.aliyun.maliang.android:queen:${latest_version}" } ``` -------------------------------- ### Integrate AUIMessage/AliVCIMCompat Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/AUIBaseKits/AUIMessage/README.md Integrate the compatibility layer for Aliyun Interactive Message SDK (new and old) using CocoaPods. This allows for dynamic switching between SDK versions. ```ruby # 方式3:集成使用阿里互动消息SDK新老兼容实现的AUIMessage pod 'AUIMessage/AliVCIMCompat', :path => 'AUIMessage/' ``` -------------------------------- ### RongCloud Constants Configuration Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIMessage/README.md Defines the APP_KEY for RongCloud integration. Replace 'xxx' with your actual APP Key obtained from the RongCloud backend. ```java interface RongCloudConsts { String APP_KEY = "xxx"; } ``` -------------------------------- ### Join Live Stream Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/iOS/README.md Enter an existing live stream by providing the live ID and the current view controller. The 'completed' block can be used for callbacks after joining. ```Objective-C // 进入直播 [[AUIInteractionLiveManager defaultManager] joinLiveWithLiveId:@"直播id" currentVC:self completed:nil]; ``` -------------------------------- ### Authenticate User Source: https://context7.com/mediabox-auikits/auiinteractionlive/llms.txt Use this endpoint to verify user credentials and obtain a JWT token for subsequent API requests. ```bash # 用户登录获取Token curl -X POST "https://your-appserver-domain/api/v1/live/login" \ -H "Content-Type: application/json" \ -d '{ "username": "test_user", "password": "test_user" }' # 返回结果 { "code": 200, "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0X3VzZXIiLCJleHAiOjE2OTk5OTk5OTl9.xxx", "expire": "2024-12-31T23:59:59" } ``` -------------------------------- ### Add Module Dependency Source: https://github.com/mediabox-auikits/auiinteractionlive/blob/main/Android/AUIBaseKits/AUIBeauty/README.md Gradle dependency for including the live_queenbeauty module in your project. ```groovy implementation project(':AUIBaseKits:AUIBeauty:live_queenbeauty') ```