basic example app: attach the video of remote participant if already available
正在显示
1 个修改的文件
包含
10 行增加
和
0 行删除
| @@ -14,6 +14,7 @@ import io.livekit.android.events.RoomEvent | @@ -14,6 +14,7 @@ import io.livekit.android.events.RoomEvent | ||
| 14 | import io.livekit.android.events.collect | 14 | import io.livekit.android.events.collect |
| 15 | import io.livekit.android.renderer.SurfaceViewRenderer | 15 | import io.livekit.android.renderer.SurfaceViewRenderer |
| 16 | import io.livekit.android.room.Room | 16 | import io.livekit.android.room.Room |
| 17 | +import io.livekit.android.room.track.Track | ||
| 17 | import io.livekit.android.room.track.VideoTrack | 18 | import io.livekit.android.room.track.VideoTrack |
| 18 | import kotlinx.coroutines.launch | 19 | import kotlinx.coroutines.launch |
| 19 | 20 | ||
| @@ -62,6 +63,15 @@ class MainActivity : AppCompatActivity() { | @@ -62,6 +63,15 @@ class MainActivity : AppCompatActivity() { | ||
| 62 | val localParticipant = room.localParticipant | 63 | val localParticipant = room.localParticipant |
| 63 | localParticipant.setMicrophoneEnabled(true) | 64 | localParticipant.setMicrophoneEnabled(true) |
| 64 | localParticipant.setCameraEnabled(true) | 65 | localParticipant.setCameraEnabled(true) |
| 66 | + | ||
| 67 | + // Attach video of remote participant if already available. | ||
| 68 | + val remoteVideoTrack = room.remoteParticipants.values.firstOrNull() | ||
| 69 | + ?.getTrackPublication(Track.Source.CAMERA) | ||
| 70 | + ?.track as? VideoTrack | ||
| 71 | + | ||
| 72 | + if (remoteVideoTrack != null) { | ||
| 73 | + attachVideo(remoteVideoTrack) | ||
| 74 | + } | ||
| 65 | } | 75 | } |
| 66 | } | 76 | } |
| 67 | 77 |
-
请 注册 或 登录 后发表评论