LiveStreamCore
模块的 LiveCoreView
实现自定义连麦和连线视图。LiveStreamCore
模块,然后创建一个 LiveCoreView
视图对象,并将其添加到自己的视图上。importLiveStreamCore
import
RTCRoomEngine
class CustomizeConncetionController: UIViewController {private let liveCoreView: LiveCoreView = {let view = LiveCoreView()return view}()override func viewDidLoad() {super.viewDidLoad()self.liveCoreView.videoViewDelegate = self// 将 liveCoreView 添加到视图上,同时设置好布局约束}}
public class CustomizeConnectionActivity extends AppCompatActivity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);LiveCoreView liveCoreView = new LiveCoreView(this);addContentView(liveCoreView,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));}}
LiveCoreView
的 代理 VideoViewDelegate
。protocol VideoViewDelegate {func createCoGuestView(userInfo: TUIUserInfo) -> UIView?func updateCoGuestView(userInfo: TUIUserInfo, modifyFlag: UserInfoModifyFlag, coGuestView: UIView)func createCoHostView(coHostUser: TUIConnectionUser) -> UIView?func updateCoHostView(coHostUser: TUIConnectionUser, modifyFlag: UserInfoModifyFlag, coHostView: UIView)}
extension CustomizeSeatViewController:SGSeatViewDelegate
{
func createCoGuestView(userInfo: TUIUserInfo) -> UIView? {
return CustomCoGuestView(userInfo: userInfo)}func updateCoGuestView(userInfo: TUIUserInfo, modifyFlag: UserInfoModifyFlag, coGuestView: UIView) {if let coGuestView = coGuestView as? CustomCoGuestView {coGuestView.updateView(withUserInfo: userInfo)}}func createCoHostView(coHostUser: TUIConnectionUser) -> UIView? {return CustomCoHostView(coHostUser: coHostUser)}func updateCoHostView(coHostUser: TUIConnectionUser, modifyFlag: UserInfoModifyFlag, coHostView: UIView)if let coHostiew = coHostiew as? CustomCoGuestView {coHostiew.updateView(withUser: coHostUser)}}}
// 请替换成您的 CoGuestViewclass CustomCoGuestView: UIView {var userInfo: TUIUserInfo = TUIUserInfo()// ... UIinit(userInfo: TUIUserInfo) {self.userInfo = userInfo}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}func updateView(withUserInfo userInfo: TUIUserInfo) {self.userInfo = userInfo// ...}}// 请替换成您的 CoHostViewclass CustomCoHostView: UIView {var coHostUser: TUIConnectionUser = TUIConnectionUser()// ... UIinit(coHostUser: TUIConnectionUser) {self.coHostUser = coHostUser}required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}func updateView(withUser user: TUIConnectionUser) {self.coHostUser = user// ...}}
LiveCoreView
的 适配器 VideoViewAdapter。public interface VideoViewAdapter {View createCoGuestView(TUIRoomDefine.UserInfo var1);void updateCoGuestView(TUIRoomDefine.UserInfo var1, List<UserInfoModifyFlag> var2, View var3);View createCoHostView(CoHostUser var1);void updateCoHostView(CoHostUser var1, List<UserInfoModifyFlag> var2, View var3);}
liveCoreView.setVideoViewAdapter(new LiveCoreViewDefine.VideoViewAdapter() {@Overridepublic View createCoGuestView(TUIRoomDefine.UserInfo userInfo) {TextView coGuestUserName = new TextView(CustomizeConnectionActivity.this);coGuestUserName.setText(userInfo.userName);return coGuestUserName;}@Overridepublic void updateCoGuestView(TUIRoomDefine.UserInfo userInfo, List<LiveCoreViewDefine.UserInfoModifyFlag> list, View view) {}@Overridepublic View createCoHostView(LiveCoreViewDefine.CoHostUser coHostUser) {TextView coHostUserName = new TextView(CustomizeConnectionActivity.this);coHostUserName.setText(coHostUser.connectionUser.userName);return coHostUserName;}@Overridepublic void updateCoHostView(LiveCoreViewDefine.CoHostUser coHostUser, List<LiveCoreViewDefine.UserInfoModifyFlag> list, View view) {}});
本页内容是否解决了您的问题?