# MultiplayerVideoDemo **Repository Path**: wecloud-framework/multiplayer-video-demo ## Basic Information - **Project Name**: MultiplayerVideoDemo - **Description**: 本项目是音视频的安卓项目示例,基于蔚可云的音视频sdk - **Primary Language**: Android - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-04-28 - **Last Updated**: 2022-06-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 多人音视频demo demo使用liveKit实现多人音视频通话,通话信令和状态的维护通过imsdk实现。所以需要同时集成imsdk与livekit ## 1. 集成livekit 项目中的`livekit.zip`是livekit的maven库,使用时需发布到自己的maven私服上, 或者解压到本地maven缓存目录下(路径:`用户目录\.m2\repository\`),在App级的gradle中添加`mavenLocal()`引用 livekit使用的是google的protobuf,所以在项目中需要配置proto文件的路径。 在项目级gradle中添加 ``` ext{ generated = [ protoSrc: "$projectDir/protocol", ] } ``` gradle引用 ``` //多人视频库 implementation "io.livekit.android:livekit:0.9.1" implementation "com.google.protobuf:protobuf-java:3.15.1" ``` ## 2. 集成imsdk imsdk已经打包为aar放在app模块的libs目录中。 因为imsdk存储发送的消息使用了Room数据库,所以需要在项目中引入 ``` def roomVersion = "2.4.1" implementation("androidx.room:room-runtime:$roomVersion") annotationProcessor("androidx.room:room-compiler:$roomVersion") // To use Kotlin annotation processing tool (kapt) kapt("androidx.room:room-compiler:$roomVersion") // optional - Kotlin Extensions and Coroutines support for Room implementation("androidx.room:room-ktx:$roomVersion") // optional - RxJava2 support for Room implementation("androidx.room:room-rxjava2:$roomVersion") // optional - Guava support for Room, including Optional and ListenableFuture implementation("androidx.room:room-guava:$roomVersion") // optional - Test helpers testImplementation("androidx.room:room-testing:$roomVersion") // optional - Paging 3 Integration implementation("androidx.room:room-paging:$roomVersion") ``` AndroidManifest需要配置PushService用于收发多人视频的信令 ``` ``` 在Application中对imsdk初始化 ``` //初始化SDK配置 WeCloud.initialize(this, HTTP_URL, WS_URL) //注册多人会议事件处理 IMMessageManager.registerMultiMeetMessageHandler(MultiMeetMsgHandler(this)) //后台WS服务配置 //设置自动唤醒 PushService.setAutoWakeUp(true) //创建通知通道 PushService.createNotificationChannel( this, "cn.wecloud.chatkitdemo", "后台运行", "消息渠道", NotificationManager.IMPORTANCE_HIGH, false, 0, false, null ) PushService.setDefaultChannelId(this, AndroidNotificationManager.DEFAULT_CHANNEL_ID) PushService.setForegroundMode(true, 123, createForegroundNotification()) PushService.setDefaultPushCallback(this, MainActivity::class.java) PushService.setNotificationIcon(R.drawable.ic_launcher_foreground) ```