Commit 3b2cace5 authored by Steven杜宇's avatar Steven杜宇

Merge branch 'yinhe-live-1212' of...

Merge branch 'yinhe-live-1212' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into yinhe-live-1212
parents 134fc51b a43251dd
...@@ -181,6 +181,7 @@ ...@@ -181,6 +181,7 @@
0430EFDA2D041F5800EC8CC0 /* YHAIEvaluationWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430EFD92D041F5800EC8CC0 /* YHAIEvaluationWebView.swift */; }; 0430EFDA2D041F5800EC8CC0 /* YHAIEvaluationWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0430EFD92D041F5800EC8CC0 /* YHAIEvaluationWebView.swift */; };
0431F8822C942D88003B84F4 /* YHResignMaterialNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */; }; 0431F8822C942D88003B84F4 /* YHResignMaterialNameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */; };
0431F8842C9579F7003B84F4 /* YHResignTemplateSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */; }; 0431F8842C9579F7003B84F4 /* YHResignTemplateSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */; };
04336E252D0817ED0070A71B /* YHLivePeopleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04336E242D0817ED0070A71B /* YHLivePeopleModel.swift */; };
04358E042C77322700811928 /* YHHaveGrabbedNumberListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */; }; 04358E042C77322700811928 /* YHHaveGrabbedNumberListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */; };
04358E062C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */; }; 04358E062C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */; };
04358E082C77657000811928 /* YHReAppointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E072C77657000811928 /* YHReAppointViewController.swift */; }; 04358E082C77657000811928 /* YHReAppointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04358E072C77657000811928 /* YHReAppointViewController.swift */; };
...@@ -1295,6 +1296,7 @@ ...@@ -1295,6 +1296,7 @@
0430EFD92D041F5800EC8CC0 /* YHAIEvaluationWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIEvaluationWebView.swift; sourceTree = "<group>"; }; 0430EFD92D041F5800EC8CC0 /* YHAIEvaluationWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAIEvaluationWebView.swift; sourceTree = "<group>"; };
0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignMaterialNameCell.swift; sourceTree = "<group>"; }; 0431F8812C942D88003B84F4 /* YHResignMaterialNameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignMaterialNameCell.swift; sourceTree = "<group>"; };
0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignTemplateSheetView.swift; sourceTree = "<group>"; }; 0431F8832C9579F7003B84F4 /* YHResignTemplateSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignTemplateSheetView.swift; sourceTree = "<group>"; };
04336E242D0817ED0070A71B /* YHLivePeopleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLivePeopleModel.swift; sourceTree = "<group>"; };
04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberListCell.swift; sourceTree = "<group>"; }; 04358E032C77322700811928 /* YHHaveGrabbedNumberListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberListCell.swift; sourceTree = "<group>"; };
04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberInfoView.swift; sourceTree = "<group>"; }; 04358E052C77334B00811928 /* YHHaveGrabbedNumberInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHaveGrabbedNumberInfoView.swift; sourceTree = "<group>"; };
04358E072C77657000811928 /* YHReAppointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHReAppointViewController.swift; sourceTree = "<group>"; }; 04358E072C77657000811928 /* YHReAppointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHReAppointViewController.swift; sourceTree = "<group>"; };
...@@ -3102,6 +3104,7 @@ ...@@ -3102,6 +3104,7 @@
04564D6D2CF6EB3D004456E4 /* YHHuanXinUserModel.swift */, 04564D6D2CF6EB3D004456E4 /* YHHuanXinUserModel.swift */,
04564D6F2CF6EC8A004456E4 /* YHRecordedDetailModel.swift */, 04564D6F2CF6EC8A004456E4 /* YHRecordedDetailModel.swift */,
04F98A2E2D00543500B1CC0A /* YHLiveCreateOrderModel.swift */, 04F98A2E2D00543500B1CC0A /* YHLiveCreateOrderModel.swift */,
04336E242D0817ED0070A71B /* YHLivePeopleModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -6561,6 +6564,7 @@ ...@@ -6561,6 +6564,7 @@
0430E6682C749128000511E2 /* YHAdopterChinaViewController.swift in Sources */, 0430E6682C749128000511E2 /* YHAdopterChinaViewController.swift in Sources */,
045EEE9F2B9F171A0022A143 /* YHWorkExperienceModel.swift in Sources */, 045EEE9F2B9F171A0022A143 /* YHWorkExperienceModel.swift in Sources */,
A5FF0F3C2C32F2460069852B /* YHActivityDetailCell1.swift in Sources */, A5FF0F3C2C32F2460069852B /* YHActivityDetailCell1.swift in Sources */,
04336E252D0817ED0070A71B /* YHLivePeopleModel.swift in Sources */,
04256E1B2C75C60C00A37BA4 /* YHHKMemberModel.swift in Sources */, 04256E1B2C75C60C00A37BA4 /* YHHKMemberModel.swift in Sources */,
04912F782CB7A11700CC3105 /* YHResignAppointOptionCell.swift in Sources */, 04912F782CB7A11700CC3105 /* YHResignAppointOptionCell.swift in Sources */,
045EEF232B9F171A0022A143 /* YHItemView.swift in Sources */, 045EEF232B9F171A0022A143 /* YHItemView.swift in Sources */,
......
...@@ -46,7 +46,7 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -46,7 +46,7 @@ class YHBasePlayerViewController: YHBaseViewController {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
//setupGestures() //setupGestures()
setupNotifications() //setupNotifications()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
...@@ -62,8 +62,8 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -62,8 +62,8 @@ class YHBasePlayerViewController: YHBaseViewController {
gk_navBarAlpha = 1 gk_navBarAlpha = 1
gk_navigationBar.isHidden = false gk_navigationBar.isHidden = false
view.backgroundColor = .black view.backgroundColor = .black
controlsAutoHideTimer?.invalidate() // controlsAutoHideTimer?.invalidate()
controlsAutoHideTimer = nil // controlsAutoHideTimer = nil
UIApplication.shared.isIdleTimerDisabled = false UIApplication.shared.isIdleTimerDisabled = false
} }
......
...@@ -23,6 +23,10 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -23,6 +23,10 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
private var listMaxWidth: CGFloat { private var listMaxWidth: CGFloat {
return KScreenWidth * 248.0 / 375.0 return KScreenWidth * 248.0 / 375.0
} }
private var isFirstAppear = true
private var timer: DispatchSourceTimer?
private var isDisappearFromZoom = false
// MARK: - UI Components // MARK: - UI Components
...@@ -106,11 +110,38 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -106,11 +110,38 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
if YHLoginManager.shared.isLogin() { if YHLoginManager.shared.isLogin() {
joinLiveRoom(id: liveId, callback: { _, _ in }) joinLiveRoom(id: liveId, callback: { _, _ in })
} }
setupTimer()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if !isFirstAppear {
if let liveDetail = viewModel.liveDetailModel, !liveDetail.rtmp_channel.isEmpty, !liveDetail.token.isEmpty, let uid = playbackInfo?.uid, let player = player {
YHPlayerManager.shared.joinChannel(for: player, token: liveDetail.token, channelId: liveDetail.rtmp_channel, uid: uid, view: playerView, defaultMuted: false)
}
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if !isDisappearFromZoom {
if let player = player {
YHPlayerManager.shared.leaveChannel(for: player)
}
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if isFirstAppear {
isFirstAppear = false
}
} }
deinit { deinit {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
quitChatRoom() quitChatRoom()
cancelTimer()
} }
// MARK: - Setup // MARK: - Setup
...@@ -136,6 +167,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -136,6 +167,7 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
} }
topBarView.zoomButtonClickEvent = { [weak self] in topBarView.zoomButtonClickEvent = { [weak self] in
self?.isDisappearFromZoom = true
self?.leaveLiveRoom() self?.leaveLiveRoom()
self?.enterFloating() self?.enterFloating()
} }
...@@ -563,6 +595,36 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -563,6 +595,36 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
@objc private func didLogOutEaseIM() { @objc private func didLogOutEaseIM() {
quitChatRoom() quitChatRoom()
} }
/// 设置定时器
private func setupTimer() {
timer = DispatchSource.makeTimerSource(queue: .main)
timer?.schedule(deadline: .now(), repeating: .seconds(120))
timer?.setEventHandler(handler: { [weak self] in
guard let self = self else {
return
}
viewModel.getLivePeople(id: liveId) { [weak self] livePeople, error in
guard let self = self else {
return
}
DispatchQueue.main.async {
if let num = livePeople?.num, num.count > 0 {
self.topBarView.updateCountLabel(num)
}
}
}
})
timer?.resume()
}
/// 取消定时器
private func cancelTimer() {
if timer != nil {
timer?.cancel()
timer = nil
}
}
} }
// MARK: - YHPlayerDelegate // MARK: - YHPlayerDelegate
......
...@@ -186,6 +186,8 @@ class YHPlayer { ...@@ -186,6 +186,8 @@ class YHPlayer {
func pause() { func pause() {
if playMode == .vod { if playMode == .vod {
playerKit?.pause() playerKit?.pause()
} else {
YHPlayerManager.shared.leaveChannel(for: self)
} }
} }
...@@ -200,19 +202,22 @@ class YHPlayer { ...@@ -200,19 +202,22 @@ class YHPlayer {
} }
func resume(withNewView view: UIView) { func resume(withNewView view: UIView) {
if let token = currentToken, if playMode == .vod {
let channelId = currentChannelId, if let url = currentURL {
let uid = currentUid { play(url: url,
YHPlayerManager.shared.joinChannel(for: self, title: currentTitle,
token: token, view: view,
channelId: channelId, isLive: playMode == .live)
uid: uid, view: view) }
} } else {
if let url = currentURL { if let token = currentToken,
play(url: url, let channelId = currentChannelId,
title: currentTitle, let uid = currentUid {
view: view, YHPlayerManager.shared.joinChannel(for: self,
isLive: playMode == .live) token: token,
channelId: channelId,
uid: uid, view: view)
}
} }
} }
......
...@@ -310,6 +310,19 @@ class YHPlayerManager: NSObject { ...@@ -310,6 +310,19 @@ class YHPlayerManager: NSObject {
bannerPlayer.pause() bannerPlayer.pause()
} }
} }
var lastVodVC: YHVODPlayerViewController?
var lastNav: UINavigationController?
var lastLiveVC: YHLivePlayerViewController?
if let topVC = UIApplication.shared.yhKeyWindow()?.rootViewController?.topMostViewController(), let nav = topVC.navigationController {
let viewControllers = nav.viewControllers
lastVodVC = viewControllers.last { vc in
vc is YHVODPlayerViewController
} as? YHVODPlayerViewController
lastLiveVC = viewControllers.last { vc in
vc is YHLivePlayerViewController
} as? YHLivePlayerViewController
lastNav = nav
}
let playerVC = YHVODPlayerViewController(id: playbackInfo.id, url: playbackInfo.url, title: playbackInfo.title) let playerVC = YHVODPlayerViewController(id: playbackInfo.id, url: playbackInfo.url, title: playbackInfo.title)
let navVC = YHNavigationController(rootViewController: playerVC) let navVC = YHNavigationController(rootViewController: playerVC)
...@@ -335,8 +348,17 @@ class YHPlayerManager: NSObject { ...@@ -335,8 +348,17 @@ class YHPlayerManager: NSObject {
if let url = playbackInfo.url { if let url = playbackInfo.url {
player.play(url: url, title: playbackInfo.title, view: playerVC.playerView) player.play(url: url, title: playbackInfo.title, view: playerVC.playerView)
} }
if let lastNav = lastNav, let lastVodVC = lastVodVC {
present(navVC, from: sourceView) lastNav.viewControllers.removeAll()
var viewControllers = lastNav.viewControllers
viewControllers.append(playerVC)
lastNav.setViewControllers(viewControllers, animated: true)
} else if let lastNav = lastNav, let lastLiveVC = lastLiveVC {
lastNav.pushViewController(playerVC, animated: true)
} else {
present(navVC, from: sourceView)
}
if needExitFloating, floatingWindow != nil { if needExitFloating, floatingWindow != nil {
floatingWindow?.dismiss() floatingWindow?.dismiss()
clearFloatingWindow() clearFloatingWindow()
...@@ -357,6 +379,19 @@ class YHPlayerManager: NSObject { ...@@ -357,6 +379,19 @@ class YHPlayerManager: NSObject {
bannerPlayer.pause() bannerPlayer.pause()
} }
} }
var lastVodVC: YHVODPlayerViewController?
var lastNav: UINavigationController?
var lastLiveVC: YHLivePlayerViewController?
if let topVC = UIApplication.shared.yhKeyWindow()?.rootViewController?.topMostViewController(), let nav = topVC.navigationController {
let viewControllers = nav.viewControllers
lastVodVC = viewControllers.last { vc in
vc is YHVODPlayerViewController
} as? YHVODPlayerViewController
lastLiveVC = viewControllers.last { vc in
vc is YHLivePlayerViewController
} as? YHLivePlayerViewController
lastNav = nav
}
let playerVC = YHLivePlayerViewController(id: playbackInfo.id, let playerVC = YHLivePlayerViewController(id: playbackInfo.id,
url: nil, url: nil,
...@@ -398,7 +433,16 @@ class YHPlayerManager: NSObject { ...@@ -398,7 +433,16 @@ class YHPlayerManager: NSObject {
player.play(url: url, title: playbackInfo.title, view: playerVC.playerView) player.play(url: url, title: playbackInfo.title, view: playerVC.playerView)
} }
present(navVC, from: sourceView) if let lastNav = lastNav, let lastLiveVC = lastLiveVC {
lastNav.viewControllers.removeAll()
var viewControllers = lastNav.viewControllers
viewControllers.append(playerVC)
lastNav.setViewControllers(viewControllers, animated: true)
} else if let lastNav = lastNav, let lastVodVC = lastVodVC {
lastNav.pushViewController(playerVC, animated: true)
} else {
present(navVC, from: sourceView)
}
if needExitFloating, floatingWindow != nil { if needExitFloating, floatingWindow != nil {
floatingWindow?.dismiss() floatingWindow?.dismiss()
clearFloatingWindow() clearFloatingWindow()
......
...@@ -21,6 +21,8 @@ class YHVODPlayerViewController: YHBasePlayerViewController { ...@@ -21,6 +21,8 @@ class YHVODPlayerViewController: YHBasePlayerViewController {
let view = YHVideoProgressControl() let view = YHVideoProgressControl()
return view return view
}() }()
private var isFirstAppear = true
// MARK: - Initialization // MARK: - Initialization
...@@ -53,6 +55,28 @@ class YHVODPlayerViewController: YHBasePlayerViewController { ...@@ -53,6 +55,28 @@ class YHVODPlayerViewController: YHBasePlayerViewController {
setupGestures() setupGestures()
loadVideoDetail() loadVideoDetail()
} }
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// if !isFirstAppear {
// player?.resume()
// }
if player?.currentURL != nil {
player?.resume()
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
player?.pause()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if isFirstAppear {
isFirstAppear = false
}
}
// MARK: - SetupView // MARK: - SetupView
......
//
// YHLivePeopleModel.swift
// galaxy
//
// Created by alexzzw on 2024/12/10.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
import SmartCodable
class YHLivePeopleModel: SmartCodable {
var num: String = ""
required init() {
}
}
...@@ -21,6 +21,7 @@ class YHLiveSalesViewModel: YHBaseViewModel { ...@@ -21,6 +21,7 @@ class YHLiveSalesViewModel: YHBaseViewModel {
var huanXinTokenModel: YHHuanXinTokenModel? var huanXinTokenModel: YHHuanXinTokenModel?
// 快速生成订单 // 快速生成订单
var orderModel: YHLiveCreateOrderModel? var orderModel: YHLiveCreateOrderModel?
var livePeople: YHLivePeopleModel?
} }
extension YHLiveSalesViewModel { extension YHLiveSalesViewModel {
...@@ -208,6 +209,31 @@ extension YHLiveSalesViewModel { ...@@ -208,6 +209,31 @@ extension YHLiveSalesViewModel {
callBackBlock(nil, err) callBackBlock(nil, err)
} }
} }
func getLivePeople(id: Int, callback: @escaping (_ livePeople: YHLivePeopleModel?, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.livePeople
_ = YHNetRequest.getRequest(url: strUrl, params: ["live_id": id]) { [weak self] json, _ in
// 1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let resultModel = YHLivePeopleModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callback(nil, err)
return
}
self?.livePeople = resultModel
callback(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(nil, err)
}
} failBlock: { err in
callback(nil, err)
}
}
} }
private extension String { private extension String {
......
...@@ -685,6 +685,8 @@ class YHAllApiName { ...@@ -685,6 +685,8 @@ class YHAllApiName {
static let joinLiveRoom = "super-app/live/app-live-join" static let joinLiveRoom = "super-app/live/app-live-join"
// 创建订单-立即购买 // 创建订单-立即购买
static let createOrder = "super-app/presale/app/order/create" static let createOrder = "super-app/presale/app/order/create"
// APP直播间人数
static let livePeople = "super-app/live/live-people"
} }
struct AIChat { struct AIChat {
......
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