Commit 116605e5 authored by Alex朱枝文's avatar Alex朱枝文

直播间流程优化,下播的leaveChannel, ui走查bug修复

parent e747a779
......@@ -275,9 +275,14 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
playbackInfo?.title = liveDetail.live_title
playbackInfo?.uid = UInt(liveDetail.user_id)
messageListView.anchorName = liveDetail.hxNickname
let isOnLive = liveDetail.getLiveState() == .onLive || liveDetail.getLiveState() == .stop
if needJoinLiveChannel {
if !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player, !player.isJoined {
if !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player, isOnLive {
YHPlayerManager.shared.joinChannel(for: player, token: liveDetail.token, channelId: liveDetail.rtmp_channel, uid: uid, view: playerView, defaultMuted: false)
} else if !isOnLive {
if let player = player {
YHPlayerManager.shared.leaveChannel(for: player)
}
}
}
// 如果没有预设roomId,使用接口返回的roomId
......@@ -601,21 +606,20 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
case .liveStart:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .liveEnd:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .livePause:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
case .liveResume:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: true)
case .liveGoodsRefresh:
self.handleLiveDetailSuccess(liveDetail, needJoinIMRoom: false, needJoinLiveChannel: false)
self.goodsListView?.dataSource = liveDetail.goods
}
} else {
printLog("YHLivePlayerViewController: 请求失败")
if let errorMsg = error?.errorMsg, !errorMsg.isEmpty {
YHHUD.flash(message: errorMsg)
}
return
// if let errorMsg = error?.errorMsg, !errorMsg.isEmpty {
// YHHUD.flash(message: errorMsg)
// }
}
}
}
......
......@@ -9,6 +9,7 @@
import UIKit
enum YHLiveState: Int {
case unknown = -1
case start = 0
case stop = 1
case end = 2
......@@ -122,7 +123,7 @@ class YHLiveStateViewController: YHBaseViewController {
view.addSubview(logImageView)
logImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(196)
make.top.equalTo(240)
make.width.height.equalTo(78)
}
......@@ -229,7 +230,7 @@ class YHLiveStateViewController: YHBaseViewController {
loginSubTitleLabel.text = "直播已结束"
messageLabel.text = "直播已结束,去首页逛逛吧~"
getCodeButton.isHidden = false
case .onLive:
case .onLive, .unknown:
break
}
}
......
......@@ -48,7 +48,7 @@ class YHLiveDetailModel: SmartCodable {
func getLiveState() -> YHLiveState {
switch status {
case 0:
return .onLive
return .unknown
case 1:
if stream_status == 3 {
return .stop
......@@ -59,7 +59,7 @@ class YHLiveDetailModel: SmartCodable {
case 3:
return .end
default:
return .onLive
return .unknown
}
}
......
......@@ -39,7 +39,6 @@ class YHLiveShopView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
//backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self
addGestureRecognizer(tap)
......@@ -51,7 +50,6 @@ class YHLiveShopView: UIView {
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
......@@ -61,7 +59,6 @@ class YHLiveShopView: UIView {
centerView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(295)
make.left.right.bottom.equalToSuperview()
// make.height.equalTo(518)
}
let headImageView = {
......@@ -150,10 +147,13 @@ class YHLiveShopView: UIView {
}
static func show(callBack: @escaping ((Int) -> Void)) -> YHLiveShopView {
let view = YHLiveShopView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
let view = YHLiveShopView(frame: CGRect(x: 0, y: KScreenWidth, width: KScreenWidth, height: KScreenHeight))
view.backData = callBack
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut) {
view.frame.origin.y = 0
} completion: { _ in }
return view
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment