Commit aeb19604 authored by Alex朱枝文's avatar Alex朱枝文

banner以及直播uid传值更改

parent 4a053f22
......@@ -77,6 +77,19 @@ class YHHomePageViewController: YHBaseViewController {
super.viewWillAppear(animated)
isTopMostAndVisible = true
YHPlayerManager.shared.handlePageChanged(isRecommendPage: true)
guard YHPlayerManager.shared.isConfigFloating != false else {
return
}
viewModel.getHomeFloatingLive { [weak self] success, error in
guard let self = self else {
return
}
if success {
if let liveInfo = self.viewModel.liveInfo {
self.setupLiveFloating(liveInfo: liveInfo)
}
}
}
}
override func viewDidAppear(_ animated: Bool) {
......@@ -117,11 +130,8 @@ class YHHomePageViewController: YHBaseViewController {
private extension YHHomePageViewController {
private func setupLiveFloating(liveInfo: YHHomeLiveInfoModel) {
printLog("#####setupLiveFloating(liveInfo: YHHomeLiveInfoModel) ")
guard YHPlayerManager.shared.isConfigFloating != false else {
return
}
if liveInfo.status == 1 {
let playbackInfo = YHPlayerManager.PlaybackInfo(id: liveInfo.id, token: liveInfo.token, channelId: liveInfo.rtmp_channel, uid: UInt(liveInfo.id), isLive: true, scene: .floating, playerType: .main)
let playbackInfo = YHPlayerManager.PlaybackInfo(id: liveInfo.id, token: liveInfo.token, channelId: liveInfo.rtmp_channel, uid: UInt(liveInfo.user_id), isLive: true, scene: .floating, playerType: .main)
YHPlayerManager.shared.enterFloating(from: nil, playbackInfo: playbackInfo, isConfigured: true)
} else {
YHPlayerManager.shared.exitFloating()
......@@ -413,16 +423,6 @@ extension YHHomePageViewController {
func getData() {
loadFirstData()
getHomeBannerData()
viewModel.getHomeFloatingLive { [weak self] success, error in
guard let self = self else {
return
}
if success {
if let liveInfo = self.viewModel.liveInfo {
setupLiveFloating(liveInfo: liveInfo)
}
}
}
}
// 请求订单数据
......
......@@ -290,7 +290,7 @@ extension YHLifeViewController: UICollectionViewDelegate, UICollectionViewDataSo
return
}
let item = self.viewModel.liveArr[indexPath.row]
let playbackInfo = YHPlayerManager.PlaybackInfo(id: item.id, url: nil, title: item.live_title, roomId: item.room_id, uid: UInt(item.id), isLive: true, scene: .fullscreen)
let playbackInfo = YHPlayerManager.PlaybackInfo(id: item.id, url: nil, title: item.live_title, roomId: item.room_id.count > 0 ? item.room_id : nil, uid: nil, isLive: true, scene: .fullscreen)
YHPlayerManager.shared.enterLive(from: nil, playbackInfo: playbackInfo)
}
}
......
......@@ -28,6 +28,7 @@ class YHBannerModel: SmartCodable {
var app_id: String = "" //声网直播
var token: String = "" //声网直播
var rtmp_channel: String = "" //声网直播
var user_id: Int = 0
//是否为本地
var isLocalItemFlag : Bool = false
......
......@@ -61,6 +61,7 @@ class YHHomeLiveInfoModel : SmartCodable {
var token: String = ""
var rtmp_channel: String = ""
var img_url: String = ""
var user_id: Int = 0
required init() {
}
}
......@@ -242,7 +242,7 @@ extension YHHomeBannerView: FSPagerViewDataSource, FSPagerViewDelegate {
YHPlayerManager.shared.leaveChannel(for: player)
player.clearPlayerView()
}
let playbackInfo = YHPlayerManager.PlaybackInfo(id: model.live_id, url: model.live_pull_url, title: nil, roomId: nil, token: model.token, channelId: model.rtmp_channel, uid: UInt(model.live_id), isLive: true, scene: .fullscreen)
let playbackInfo = YHPlayerManager.PlaybackInfo(id: model.live_id, url: model.live_pull_url, title: nil, roomId: nil, token: model.token, channelId: model.rtmp_channel, uid: model.user_id != 0 ? UInt(model.user_id) : nil, isLive: true, scene: .fullscreen)
YHPlayerManager.shared.enterLive(from: cell?.bannerImagV, playbackInfo: playbackInfo)
printLog("跳转直播")
case 101://录播
......
......@@ -119,7 +119,7 @@ extension YHSelectLookView: UICollectionViewDelegate, UICollectionViewDataSource
}
YHAnalytics.track("APP_GalaxySelectionPage_LiveAvatar")
let item = items[indexPath.row]
let playbackInfo = YHPlayerManager.PlaybackInfo(id: item.id, url: nil, title: item.live_title, roomId: item.room_id, uid: UInt(item.id), isLive: true, scene: .fullscreen)
let playbackInfo = YHPlayerManager.PlaybackInfo(id: item.id, url: nil, title: item.live_title, roomId: item.room_id.count > 0 ? item.room_id : nil, uid: nil, isLive: true, scene: .fullscreen)
YHPlayerManager.shared.enterLive(from: nil, playbackInfo: playbackInfo)
}
}
......
......@@ -205,6 +205,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
playbackInfo?.channelId = liveDetail.rtmp_channel
playbackInfo?.token = liveDetail.token
playbackInfo?.title = liveDetail.live_title
playbackInfo?.uid = UInt(liveDetail.user_id)
messageListView.anchorName = liveDetail.hxNickname
if needJoinLiveChannel {
if !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player {
......
......@@ -150,13 +150,20 @@ class YHPlayerManager: NSObject {
// 清理播放信息
currentPlaybackInfo.removeAll()
floatingWindow?.dismiss()
floatingWindow = nil
clearFloatingWindow()
// 重置主播放器
if let mainPlayer = activePlayers[.main] {
mainPlayer.reset()
}
}
private func clearFloatingWindow() {
floatingWindow = nil
if isInRecommendPage {
enableBannerAutoPlay()
}
}
deinit {
activePlayers.forEach { $0.value.releasePlayer() }
......@@ -332,7 +339,7 @@ class YHPlayerManager: NSObject {
present(navVC, from: sourceView)
if needExitFloating, floatingWindow != nil {
floatingWindow?.dismiss()
floatingWindow = nil
clearFloatingWindow()
}
}
......@@ -394,7 +401,7 @@ class YHPlayerManager: NSObject {
present(navVC, from: sourceView)
if needExitFloating, floatingWindow != nil {
floatingWindow?.dismiss()
floatingWindow = nil
clearFloatingWindow()
}
}
......@@ -581,7 +588,7 @@ class YHPlayerManager: NSObject {
floatingWindow?.player?.stop()
}
floatingWindow?.dismiss()
floatingWindow = nil
clearFloatingWindow()
}
private func present(_ playerVC: UIViewController, from sourceView: UIView?) {
......@@ -664,8 +671,7 @@ extension YHPlayerManager: YHFloatingWindowDelegate {
}
let player = player(for: playerType)
//player.stop()
floatingWindow = nil
clearFloatingWindow()
leaveChannel(for: player)
if window.source == .configured {
isConfigFloating = false
......@@ -729,27 +735,18 @@ extension YHPlayerManager {
self.isInRecommendPage = isRecommendPage
if isRecommendPage {
if isConfigFloating == true {
if let window = floatingWindow,
let player = window.player, window.source == .configured {
window.isHidden = false
if let window = floatingWindow, let player = window.player, window.source == .configured {
stopBannerPlayback()
resumeConfiguredFloatingWindow(window, player)
}
stopBannerPlayback()
} else {
if let window = floatingWindow,
let player = window.player, window.source == .configured {
// window.isHidden = true
// stopConfiguredFloatingWindow(window, player)
if let window = floatingWindow, window.source == .configured {
exitFloating()
}
enableBannerAutoPlay()
//resumeBannerPlayback()
}
} else {
if let window = floatingWindow,
let player = window.player, window.source == .configured {
// window.isHidden = true
// stopConfiguredFloatingWindow(window, player)
if let window = floatingWindow, window.source == .configured {
exitFloating()
}
stopBannerPlayback()
......@@ -831,8 +828,7 @@ extension YHPlayerManager {
}
func shouldPlayBanner() -> Bool {
if let window = floatingWindow,
!window.isHidden {
if floatingWindow != nil {
return false
}
return bannerAutoPlayEnabled
......
......@@ -43,6 +43,7 @@ class YHLiveDetailModel: SmartCodable {
var actual_start_time: String = ""
// 实际结束时间
var actual_end_time: String = ""
var user_id: Int = 0
func getLiveState() -> YHLiveState {
switch status {
......
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