"观众角色的用户一般需要获取房间内的合流,然后订阅。(来源参考:https://www.rongcloud.cn/?utm_source=SEO&utm_term=jishitongxun)
mRtcRoom.getLiveStreams(); //适用于 观众订阅主播合流
final ListinputStreams = mRtcRoom.getLiveStreams();
for (RCRTCInputStream inputStream : inputStreams) {
if (inputStream.getMediaType() == RCRTCMediaType.VIDEO) {
//选择订阅大流或是小流。
((RCRTCVideoInputStream) inputStream).setStreamType(RCRTCStreamType.NORMAL);
}
}
if (inputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});
主播角色的用户一般只需要在连麦场景下订阅房间内其他主播的资源。
mRtcRoom.getRemoteUsers().getStreams(); 适用于 主播订阅房间内其他主播的资源,在主播连麦的场景下会用到该方法。
ListsubscribeInputStreams = new ArrayList<>();
for (final RCRTCRemoteUser remoteUser : mRtcRoom.getRemoteUsers()) {
if (remoteUser.getStreams().size() == 0) {
continue;
}
ListuserStreams = remoteUser.getStreams();
for (RCRTCInputStream inputStream : userStreams) {
if (inputStream.getMediaType() == RCRTCMediaType.VIDEO) {
//选择订阅大流或是小流。
((RCRTCVideoInputStream) inputStream).setStreamType(RCRTCStreamType.NORMAL);
}
}
subscribeInputStreams.addAll(userStreams);
}
if (subscribeInputStreams.size() == 0) {
return;
}
mRtcRoom.getLocalUser().subscribeStreams(subscribeInputStreams, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});"