Commit bfc8a6b5 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 226cad21 1b6dc0bc
...@@ -858,6 +858,8 @@ ...@@ -858,6 +858,8 @@
04F957452C1FEC4A003C631C /* YHMessageBellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F957442C1FEC4A003C631C /* YHMessageBellView.swift */; }; 04F957452C1FEC4A003C631C /* YHMessageBellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F957442C1FEC4A003C631C /* YHMessageBellView.swift */; };
04F957472C203033003C631C /* YHMyGoodFriendsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F957462C203033003C631C /* YHMyGoodFriendsVC.swift */; }; 04F957472C203033003C631C /* YHMyGoodFriendsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F957462C203033003C631C /* YHMyGoodFriendsVC.swift */; };
04F9574B2C2032D8003C631C /* YHMyFriendsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F9574A2C2032D8003C631C /* YHMyFriendsCell.swift */; }; 04F9574B2C2032D8003C631C /* YHMyFriendsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F9574A2C2032D8003C631C /* YHMyFriendsCell.swift */; };
04F98A2F2D00543500B1CC0A /* YHLiveCreateOrderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F98A2E2D00543500B1CC0A /* YHLiveCreateOrderModel.swift */; };
04F98A312D00889C00B1CC0A /* YHVideoProgressControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F98A302D00889C00B1CC0A /* YHVideoProgressControl.swift */; };
04FA8B2B2C06F59D00ABE43F /* YHAppleLoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */; }; 04FA8B2B2C06F59D00ABE43F /* YHAppleLoginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */; };
04FA8B2E2C084C7E00ABE43F /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */; }; 04FA8B2E2C084C7E00ABE43F /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */; };
04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */; }; 04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */; };
...@@ -1969,6 +1971,8 @@ ...@@ -1969,6 +1971,8 @@
04F957442C1FEC4A003C631C /* YHMessageBellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMessageBellView.swift; sourceTree = "<group>"; }; 04F957442C1FEC4A003C631C /* YHMessageBellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMessageBellView.swift; sourceTree = "<group>"; };
04F957462C203033003C631C /* YHMyGoodFriendsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyGoodFriendsVC.swift; sourceTree = "<group>"; }; 04F957462C203033003C631C /* YHMyGoodFriendsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyGoodFriendsVC.swift; sourceTree = "<group>"; };
04F9574A2C2032D8003C631C /* YHMyFriendsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFriendsCell.swift; sourceTree = "<group>"; }; 04F9574A2C2032D8003C631C /* YHMyFriendsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyFriendsCell.swift; sourceTree = "<group>"; };
04F98A2E2D00543500B1CC0A /* YHLiveCreateOrderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveCreateOrderModel.swift; sourceTree = "<group>"; };
04F98A302D00889C00B1CC0A /* YHVideoProgressControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHVideoProgressControl.swift; sourceTree = "<group>"; };
04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAppleLoginManager.swift; sourceTree = "<group>"; }; 04FA8B2A2C06F59D00ABE43F /* YHAppleLoginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAppleLoginManager.swift; sourceTree = "<group>"; };
04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; }; 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; };
04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOneKeyLoginViewModel.swift; sourceTree = "<group>"; }; 04FA8B2F2C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOneKeyLoginViewModel.swift; sourceTree = "<group>"; };
...@@ -3077,6 +3081,7 @@ ...@@ -3077,6 +3081,7 @@
04013E412CFADF6B001A8E40 /* YHShareAlertView.swift */, 04013E412CFADF6B001A8E40 /* YHShareAlertView.swift */,
04013E452CFDA9AD001A8E40 /* YHLiveShopView.swift */, 04013E452CFDA9AD001A8E40 /* YHLiveShopView.swift */,
0413A9B02CFFDB9A00304BC6 /* YHCategoryDropdownView.swift */, 0413A9B02CFFDB9A00304BC6 /* YHCategoryDropdownView.swift */,
04F98A302D00889C00B1CC0A /* YHVideoProgressControl.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -3088,6 +3093,7 @@ ...@@ -3088,6 +3093,7 @@
04564D692CF6C0FC004456E4 /* YHLiveDetailModel.swift */, 04564D692CF6C0FC004456E4 /* YHLiveDetailModel.swift */,
04564D6D2CF6EB3D004456E4 /* YHHuanXinUserModel.swift */, 04564D6D2CF6EB3D004456E4 /* YHHuanXinUserModel.swift */,
04564D6F2CF6EC8A004456E4 /* YHRecordedDetailModel.swift */, 04564D6F2CF6EC8A004456E4 /* YHRecordedDetailModel.swift */,
04F98A2E2D00543500B1CC0A /* YHLiveCreateOrderModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -6385,6 +6391,7 @@ ...@@ -6385,6 +6391,7 @@
045EEEDF2B9F171A0022A143 /* YHCollegeSearchBar.swift in Sources */, 045EEEDF2B9F171A0022A143 /* YHCollegeSearchBar.swift in Sources */,
0471BF622CBA9046003B7942 /* YHHKVisaRenewalPersonType.swift in Sources */, 0471BF622CBA9046003B7942 /* YHHKVisaRenewalPersonType.swift in Sources */,
044D0BEE2C2019C100C5CF5E /* YHCommunityViewController.swift in Sources */, 044D0BEE2C2019C100C5CF5E /* YHCommunityViewController.swift in Sources */,
04F98A312D00889C00B1CC0A /* YHVideoProgressControl.swift in Sources */,
A567E5B52BD7643D00D5D5A0 /* YHSearchInfoBar.swift in Sources */, A567E5B52BD7643D00D5D5A0 /* YHSearchInfoBar.swift in Sources */,
044EE2462C93E22E00A2FE3A /* YHResignCertificateDetailHkViewController.swift in Sources */, 044EE2462C93E22E00A2FE3A /* YHResignCertificateDetailHkViewController.swift in Sources */,
A5ACE94B2B4564F7002C94D2 /* YHHUDRotatingImageView.swift in Sources */, A5ACE94B2B4564F7002C94D2 /* YHHUDRotatingImageView.swift in Sources */,
...@@ -6963,6 +6970,7 @@ ...@@ -6963,6 +6970,7 @@
045EEE872B9F171A0022A143 /* YHPreviewControllerHoldViewController.swift in Sources */, 045EEE872B9F171A0022A143 /* YHPreviewControllerHoldViewController.swift in Sources */,
0419A0A22C49099A00A5FCFA /* YHInvitationWithGiftsShareBottomView.swift in Sources */, 0419A0A22C49099A00A5FCFA /* YHInvitationWithGiftsShareBottomView.swift in Sources */,
04AAA8DC2BF5E5A200FE9FD5 /* YHEmptyDataView.swift in Sources */, 04AAA8DC2BF5E5A200FE9FD5 /* YHEmptyDataView.swift in Sources */,
04F98A2F2D00543500B1CC0A /* YHLiveCreateOrderModel.swift in Sources */,
044F39502CB80706007CA277 /* YHVisaRenewalPayStatusCell.swift in Sources */, 044F39502CB80706007CA277 /* YHVisaRenewalPayStatusCell.swift in Sources */,
A5A89FD72C256B94005A71DD /* YHHomeLastMessageModel.swift in Sources */, A5A89FD72C256B94005A71DD /* YHHomeLastMessageModel.swift in Sources */,
045EEF172B9F171A0022A143 /* YHSelectCountryViewController.swift in Sources */, 045EEF172B9F171A0022A143 /* YHSelectCountryViewController.swift in Sources */,
......
...@@ -32,12 +32,6 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -32,12 +32,6 @@ class YHBasePlayerViewController: YHBaseViewController {
return view return view
}() }()
private(set) lazy var controlView: YHPlayerControlView = {
let view = YHPlayerControlView()
view.delegate = self
return view
}()
lazy var topBarView: YHPlayerTopBarView = { lazy var topBarView: YHPlayerTopBarView = {
let view = YHPlayerTopBarView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: k_Height_NavigationtBarAndStatuBar)) let view = YHPlayerTopBarView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: k_Height_NavigationtBarAndStatuBar))
return view return view
...@@ -51,13 +45,12 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -51,13 +45,12 @@ class YHBasePlayerViewController: YHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
setupGestures() //setupGestures()
setupNotifications() setupNotifications()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
// navigationController?.setNavigationBarHidden(true, animated: animated)
gk_navBarAlpha = 0 gk_navBarAlpha = 0
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
view.backgroundColor = .black view.backgroundColor = .black
...@@ -65,7 +58,6 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -65,7 +58,6 @@ class YHBasePlayerViewController: YHBaseViewController {
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
// navigationController?.setNavigationBarHidden(false, animated: animated)
gk_navBarAlpha = 1 gk_navBarAlpha = 1
gk_navigationBar.isHidden = false gk_navigationBar.isHidden = false
view.backgroundColor = .black view.backgroundColor = .black
...@@ -84,7 +76,6 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -84,7 +76,6 @@ class YHBasePlayerViewController: YHBaseViewController {
view.backgroundColor = .black view.backgroundColor = .black
view.addSubview(containerView) view.addSubview(containerView)
containerView.addSubview(playerView) containerView.addSubview(playerView)
containerView.addSubview(controlView)
containerView.addSubview(topBarView) containerView.addSubview(topBarView)
setupConstraints() setupConstraints()
} }
...@@ -98,10 +89,6 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -98,10 +89,6 @@ class YHBasePlayerViewController: YHBaseViewController {
make.edges.equalToSuperview() make.edges.equalToSuperview()
} }
controlView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
topBarView.snp.makeConstraints { make in topBarView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview() make.top.left.right.equalToSuperview()
make.height.equalTo(k_Height_NavigationtBarAndStatuBar) make.height.equalTo(k_Height_NavigationtBarAndStatuBar)
...@@ -120,7 +107,7 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -120,7 +107,7 @@ class YHBasePlayerViewController: YHBaseViewController {
private func toggleControls() { private func toggleControls() {
isControlsVisible.toggle() isControlsVisible.toggle()
controlView.showControls(isControlsVisible) //controlView.showControls(isControlsVisible)
resetControlsAutoHideTimer() resetControlsAutoHideTimer()
} }
...@@ -135,49 +122,10 @@ class YHBasePlayerViewController: YHBaseViewController { ...@@ -135,49 +122,10 @@ class YHBasePlayerViewController: YHBaseViewController {
private func hideControls() { private func hideControls() {
isControlsVisible = false isControlsVisible = false
controlView.showControls(false) //controlView.showControls(false)
} }
} }
// MARK: - YHPlayerControlViewDelegate
extension YHBasePlayerViewController: YHPlayerControlViewDelegate {
func playerControlView(_ view: YHPlayerControlView, didTapBack button: UIButton) {
if let navigationController = navigationController {
navigationController.popViewController(animated: true)
} else {
dismiss(animated: true)
}
}
func playerControlView(_ view: YHPlayerControlView, didTapPlay button: UIButton) {
if player?.getPlayState() == .playing {
YHPlayerManager.shared.pause()
} else {
YHPlayerManager.shared.resume()
}
}
func playerControlView(_ view: YHPlayerControlView, didSeekTo position: Float) {
guard let player = player else { return }
let duration = player.getDuration()
let targetPosition = Int(Float(duration) * position)
player.playerKit?.seek(toPosition: targetPosition)
}
func playerControlView(_ view: YHPlayerControlView, didChangeQuality quality: YHVideoQuality) {
// 由子类实现
}
func playerControlView(_ view: YHPlayerControlView, didTapFullscreen button: UIButton) {
if UIDevice.current.orientation.isPortrait {
let value = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
} else {
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}
}
}
// MARK: - Notifications // MARK: - Notifications
extension YHBasePlayerViewController { extension YHBasePlayerViewController {
......
...@@ -6,119 +6,6 @@ ...@@ -6,119 +6,6 @@
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved. // Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
// //
//import AgoraRtcKit
//import Foundation
//
//// MARK: - 播放器类型
//
//enum YHPlayerType {
// case main
// case secondary
//}
//
//protocol YHPlayerDelegate: AnyObject {
// func player(_ player: YHPlayer, didChangedToState state: AgoraMediaPlayerState, reason: AgoraMediaPlayerReason)
// func player(_ player: YHPlayer, didChangedToPosition position: Int)
// func player(_ player: YHPlayer, didReceiveVideoSize size: CGSize)
//}
//
//// MARK: - 播放器实例封装
//
//class YHPlayer {
// weak var delegate: YHPlayerDelegate?
// let type: YHPlayerType
// var playerKit: AgoraRtcMediaPlayerProtocol?
// weak var agoraKit: AgoraRtcEngineKit?
//
// private(set) var currentURL: String?
// weak var currentPlayView: UIView?
// private(set) var currentTitle: String?
// private(set) var currentChannelId: String?
// private(set) var currentUid: UInt?
// private(set) var isJoined: Bool = false
//
// var isMuted: Bool {
// get { playerKit?.getMute() ?? false }
// set { playerKit?.mute(newValue) }
// }
//
// init(type: YHPlayerType, playerKit: AgoraRtcMediaPlayerProtocol?, agoraKit: AgoraRtcEngineKit?) {
// self.type = type
// self.playerKit = playerKit
// self.agoraKit = agoraKit
// // 基础设置
// playerKit?.setLoopCount(-1)
// }
//
// func setPlayView(_ view: UIView?) {
// currentPlayView = view
// playerKit?.setRenderMode(.fit)
// playerKit?.setView(view)
// }
//
// func setJoinInfo(channelId: String, uid: UInt) {
// currentChannelId = channelId
// currentUid = uid
// isJoined = true
// }
//
// func clearJoinInfo() {
// currentChannelId = nil
// currentUid = nil
// isJoined = false
// }
//
// func play(url: String, title: String? = nil) {
// currentURL = url
// currentTitle = title
// let mediaSource = AgoraMediaSource()
// mediaSource.url = url
// mediaSource.autoPlay = true
// let result = playerKit?.open(with: mediaSource)
// if result == 0 {
// playerKit?.play()
// }
// }
//
// func stop() {
// playerKit?.stop()
// currentPlayView = nil
// currentURL = nil
// currentTitle = nil
// }
//
// func pause() {
// playerKit?.pause()
// }
//
// func resume() {
// playerKit?.play()
// }
//
// func reset() {
// stop()
// setPlayView(nil)
// delegate = nil
// }
//
// func releasePlayer() {
// reset()
// playerKit = nil
// }
//
// func getPosition() -> Int {
// return playerKit?.getPosition() ?? 0
// }
//
// func getDuration() -> Int {
// return playerKit?.getDuration() ?? 0
// }
//
// func getPlayState() -> AgoraMediaPlayerState {
// return playerKit?.getPlayerState() ?? .idle
// }
//}
import AgoraRtcKit import AgoraRtcKit
import Foundation import Foundation
...@@ -132,6 +19,7 @@ protocol YHPlayerDelegate: AnyObject { ...@@ -132,6 +19,7 @@ protocol YHPlayerDelegate: AnyObject {
func player(_ player: YHPlayer, didChangedToState state: AgoraMediaPlayerState, reason: AgoraMediaPlayerReason) func player(_ player: YHPlayer, didChangedToState state: AgoraMediaPlayerState, reason: AgoraMediaPlayerReason)
func player(_ player: YHPlayer, didChangedToPosition position: Int) func player(_ player: YHPlayer, didChangedToPosition position: Int)
func player(_ player: YHPlayer, didReceiveVideoSize size: CGSize) func player(_ player: YHPlayer, didReceiveVideoSize size: CGSize)
func player(_ player: YHPlayer, didChangedTo positionMs: Int, atTimestamp timestampMs: TimeInterval)
} }
// MARK: - 播放器实例封装 // MARK: - 播放器实例封装
...@@ -234,10 +122,13 @@ class YHPlayer { ...@@ -234,10 +122,13 @@ class YHPlayer {
currentTitle = nil currentTitle = nil
} }
func play(url: String, title: String? = nil) { func play(url: String, title: String? = nil, view: UIView?) {
currentURL = url currentURL = url
currentTitle = title currentTitle = title
lastPlaybackInfo = (url, title) // 保存播放信息 lastPlaybackInfo = (url, title) // 保存播放信息
currentPlayView = view
playerKit?.setRenderMode(.fit)
playerKit?.setView(view)
let mediaSource = AgoraMediaSource() let mediaSource = AgoraMediaSource()
mediaSource.url = url mediaSource.url = url
...@@ -271,7 +162,7 @@ class YHPlayer { ...@@ -271,7 +162,7 @@ class YHPlayer {
func resume(withNewView view: UIView) { func resume(withNewView view: UIView) {
// 设置新的播放视图 // 设置新的播放视图
setPlayView(view) //setPlayView(view)
// 如果有频道信息,通知 Manager 重新加入频道 // 如果有频道信息,通知 Manager 重新加入频道
if let token = currentToken, if let token = currentToken,
...@@ -286,7 +177,7 @@ class YHPlayer { ...@@ -286,7 +177,7 @@ class YHPlayer {
// 如果有上次的播放信息,重新播放 // 如果有上次的播放信息,重新播放
if let lastInfo = lastPlaybackInfo, if let lastInfo = lastPlaybackInfo,
let url = lastInfo.url { let url = lastInfo.url {
play(url: url, title: lastInfo.title) play(url: url, title: lastInfo.title, view: view)
} }
} }
......
...@@ -106,7 +106,7 @@ class YHPlayerManager: NSObject { ...@@ -106,7 +106,7 @@ class YHPlayerManager: NSObject {
if let view = view { if let view = view {
player.setPlayView(view) player.setPlayView(view)
} }
player.play(url: url, title: title) player.play(url: url, title: title, view: view)
} }
func pause(type: YHPlayerType = .main) { func pause(type: YHPlayerType = .main) {
...@@ -292,7 +292,7 @@ class YHPlayerManager: NSObject { ...@@ -292,7 +292,7 @@ class YHPlayerManager: NSObject {
exitFloating() exitFloating()
if let url = playbackInfo.url { if let url = playbackInfo.url {
player.play(url: url, title: playbackInfo.title) player.play(url: url, title: playbackInfo.title, view: playerVC.playerView)
} }
present(playerVC, from: sourceView) present(playerVC, from: sourceView)
...@@ -329,7 +329,7 @@ class YHPlayerManager: NSObject { ...@@ -329,7 +329,7 @@ class YHPlayerManager: NSObject {
let channelId = playbackInfo.channelId, let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty { let channelId = playbackInfo.channelId, let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty {
joinChannel(for: player, token: token, channelId: channelId, uid: uid) joinChannel(for: player, token: token, channelId: channelId, uid: uid)
} else if let url = playbackInfo.url, url.count > 0 { } else if let url = playbackInfo.url, url.count > 0 {
player.play(url: url, title: playbackInfo.title) player.play(url: url, title: playbackInfo.title, view: playerVC.playerView)
} }
present(navVC, from: sourceView) present(navVC, from: sourceView)
...@@ -339,32 +339,13 @@ class YHPlayerManager: NSObject { ...@@ -339,32 +339,13 @@ class YHPlayerManager: NSObject {
guard let window = UIApplication.shared.yhKeyWindow() else { return } guard let window = UIApplication.shared.yhKeyWindow() else { return }
let playerType = determinePlayerType(for: .floating) let playerType = determinePlayerType(for: .floating)
let player: YHPlayer// = player(for: playerType) let player: YHPlayer = player(for: playerType)
var updatedInfo = playbackInfo var updatedInfo = playbackInfo
updatedInfo.scene = .floating updatedInfo.scene = .floating
updatedInfo.playerType = playerType updatedInfo.playerType = playerType
currentPlaybackInfo[playerType] = updatedInfo currentPlaybackInfo[playerType] = updatedInfo
// 检查是否存在当前播放器
if let existingPlayer = activePlayers[playerType],
currentPlaybackInfo[playerType] == playbackInfo {
// 使用现有播放器
player = existingPlayer
} else {
// 创建新播放器
player = self.player(for: playerType)
// 加入频道
if let token = playbackInfo.token,
let channelId = playbackInfo.channelId,
let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty {
joinChannel(for: player, token: token, channelId: channelId, uid: uid)
} else if let url = playbackInfo.url, !url.isEmpty {
player.play(url: url, title: playbackInfo.title)
}
}
// // 加入频道 // // 加入频道
// if let token = playbackInfo.token, // if let token = playbackInfo.token,
// let channelId = playbackInfo.channelId, let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty { // let channelId = playbackInfo.channelId, let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty {
...@@ -392,6 +373,15 @@ class YHPlayerManager: NSObject { ...@@ -392,6 +373,15 @@ class YHPlayerManager: NSObject {
// 计算目标位置 // 计算目标位置
let targetFrame = floatingWindow.calculateInitialFrame() let targetFrame = floatingWindow.calculateInitialFrame()
// 检查是否存在当前播放器
// 加入频道
if let token = playbackInfo.token,
let channelId = playbackInfo.channelId,
let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty {
joinChannel(for: player, token: token, channelId: channelId, uid: uid)
} else if let url = playbackInfo.url, !url.isEmpty {
player.play(url: url, title: playbackInfo.title, view: floatingWindow.contentView)
}
// 执行动画 // 执行动画
let showFloatingWindow = { let showFloatingWindow = {
...@@ -417,6 +407,14 @@ class YHPlayerManager: NSObject { ...@@ -417,6 +407,14 @@ class YHPlayerManager: NSObject {
floatingWindow.player = player floatingWindow.player = player
floatingWindow.playbackInfo = updatedInfo floatingWindow.playbackInfo = updatedInfo
self.floatingWindow = floatingWindow self.floatingWindow = floatingWindow
// 检查是否存在当前播放器
if let token = playbackInfo.token,
let channelId = playbackInfo.channelId,
let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty {
joinChannel(for: player, token: token, channelId: channelId, uid: uid)
} else if let url = playbackInfo.url, !url.isEmpty {
player.play(url: url, title: playbackInfo.title, view: floatingWindow.contentView)
}
let showFloatingWindow = { let showFloatingWindow = {
floatingWindow.show(in: window) floatingWindow.show(in: window)
...@@ -448,7 +446,7 @@ class YHPlayerManager: NSObject { ...@@ -448,7 +446,7 @@ class YHPlayerManager: NSObject {
let channelId = playbackInfo.channelId, let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty { let channelId = playbackInfo.channelId, let uid = playbackInfo.uid, !token.isEmpty, !channelId.isEmpty {
joinChannel(for: player, token: token, channelId: channelId, uid: uid) joinChannel(for: player, token: token, channelId: channelId, uid: uid)
} else if let url = playbackInfo.url, !url.isEmpty { } else if let url = playbackInfo.url, !url.isEmpty {
player.play(url: url, title: playbackInfo.title) player.play(url: url, title: playbackInfo.title, view: view)
} }
} }
...@@ -487,6 +485,12 @@ extension YHPlayerManager: AgoraRtcMediaPlayerDelegate { ...@@ -487,6 +485,12 @@ extension YHPlayerManager: AgoraRtcMediaPlayerDelegate {
player.delegate?.player(player, didChangedToPosition: position) player.delegate?.player(player, didChangedToPosition: position)
} }
} }
func AgoraRtcMediaPlayer(_ playerKit: any AgoraRtcMediaPlayerProtocol, didChangedTo positionMs: Int, atTimestamp timestampMs: TimeInterval) {
if let player = activePlayers.values.first(where: { $0.playerKit === playerKit }) {
player.delegate?.player(player, didChangedTo: positionMs, atTimestamp: timestampMs)
}
}
func AgoraRtcMediaPlayer(_ playerKit: AgoraRtcMediaPlayerProtocol, func AgoraRtcMediaPlayer(_ playerKit: AgoraRtcMediaPlayerProtocol,
infoUpdated info: AgoraMediaPlayerUpdatedInfo) { infoUpdated info: AgoraMediaPlayerUpdatedInfo) {
......
...@@ -22,6 +22,11 @@ enum YHChatRoomCustomEvent: String { ...@@ -22,6 +22,11 @@ enum YHChatRoomCustomEvent: String {
case liveGoodsRefresh = "chatRoomCustomEventLiveGoodsRefresh" case liveGoodsRefresh = "chatRoomCustomEventLiveGoodsRefresh"
} }
struct YHChatRoomCustomLocal {
static let tipsEvent = "YHLiveRoomTips"
static let tipsKey = "tips"
}
class YHIMHelper: NSObject { class YHIMHelper: NSObject {
static let didLoginEaseIMSuccess = Notification.Name("com.YHIMHelper.didLoginEaseIMSuccess") static let didLoginEaseIMSuccess = Notification.Name("com.YHIMHelper.didLoginEaseIMSuccess")
static let didLogOutEaseIM = Notification.Name("com.YHIMHelper.didLogOutEaseIM") static let didLogOutEaseIM = Notification.Name("com.YHIMHelper.didLogOutEaseIM")
......
//
// YHLiveCreateOrderModel.swift
// galaxy
//
// Created by alexzzw on 2024/12/4.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
import SmartCodable
class YHLiveCreateOrderModel: SmartCodable {
var id: Int = 0
required init() {
}
}
...@@ -75,6 +75,7 @@ class YHLiveGoodsItem: SmartCodable { ...@@ -75,6 +75,7 @@ class YHLiveGoodsItem: SmartCodable {
var linePrice: String = "" var linePrice: String = ""
var sn: String = "" var sn: String = ""
var banner: String = "" var banner: String = ""
var flag: Int = 0
required init() { required init() {
} }
......
...@@ -14,9 +14,11 @@ class YHRecordedDetailModel: SmartCodable { ...@@ -14,9 +14,11 @@ class YHRecordedDetailModel: SmartCodable {
var avatar: String = "" var avatar: String = ""
var access_num: Int = 0 var access_num: Int = 0
var tips: String = "" var tips: String = ""
var subject: String = ""
var recorded_url: String = "" var recorded_url: String = ""
var recorded_cover: String = "" var recorded_image: String = ""
var recorded_title: String = ""
var recorded_h5_url: String = ""
var goods: [YHLiveGoodsItem] = [] var goods: [YHLiveGoodsItem] = []
var recordedVideoCate: [YHRecordedVideoCategoryItem] = [] var recordedVideoCate: [YHRecordedVideoCategoryItem] = []
var recordedVideoSlice: [YHRecordedVideoSliceItem] = [] var recordedVideoSlice: [YHRecordedVideoSliceItem] = []
...@@ -34,8 +36,8 @@ class YHRecordedVideoCategoryItem: SmartCodable { ...@@ -34,8 +36,8 @@ class YHRecordedVideoCategoryItem: SmartCodable {
} }
class YHRecordedVideoSliceItem: SmartCodable { class YHRecordedVideoSliceItem: SmartCodable {
var startSecond: String = "" var start_second: Int = 0
var endSecond: String = "" var end_second: Int = 0
var tag: String = "" var tag: String = ""
var index: Int = 0 var index: Int = 0
......
...@@ -67,4 +67,10 @@ class YHLiveMessageCell: UITableViewCell { ...@@ -67,4 +67,10 @@ class YHLiveMessageCell: UITableViewCell {
let contentAtt = ASAttributedString(string: content, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13))) let contentAtt = ASAttributedString(string: content, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13)))
contentLabel.attributed.text = nickAtt + contentAtt contentLabel.attributed.text = nickAtt + contentAtt
} }
func configureTipsMessage(_ tips: String) {
let tipsIcon = ASAttributedString.init(.image(UIImage(named: "live_msg_tips_icon") ?? UIImage(), .custom(.offset(CGPoint(x: 0, y: -4.0)), size: .init(width: 32, height: 18))))
let contentAtt = (tipsIcon + ASAttributedString(string: tips, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13))))
contentLabel.attributed.text = contentAtt
}
} }
...@@ -107,8 +107,11 @@ extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource { ...@@ -107,8 +107,11 @@ extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource {
printLog(body.text) printLog(body.text)
printLog("\(nickName) : \(body.text)") printLog("\(nickName) : \(body.text)")
content = body.text content = body.text
cell.configureNormalMessage(nickName, content)
} else if let body = message.body as? EMCustomMessageBody, body.event == YHChatRoomCustomLocal.tipsEvent, let customExt = body.customExt, let tips = customExt[YHChatRoomCustomLocal.tipsKey] {
cell.configureTipsMessage(tips)
} }
cell.configureNormalMessage(nickName, content)
return cell return cell
} }
} }
...@@ -12,6 +12,7 @@ import AttributedString ...@@ -12,6 +12,7 @@ import AttributedString
class YHLiveShopView: UIView { class YHLiveShopView: UIView {
var closeEvent: (() -> Void)? var closeEvent: (() -> Void)?
var backData: ((Int) -> Void)? var backData: ((Int) -> Void)?
var buyData: ((Int) -> Void)?
var centerView: UIView! var centerView: UIView!
var titleLabel: UILabel! var titleLabel: UILabel!
var subTitleLabel: UILabel! var subTitleLabel: UILabel!
...@@ -175,7 +176,11 @@ extension YHLiveShopView: UITableViewDelegate, UITableViewDataSource { ...@@ -175,7 +176,11 @@ extension YHLiveShopView: UITableViewDelegate, UITableViewDataSource {
} }
let model = dataSource[indexPath.row] let model = dataSource[indexPath.row]
let cell = tableView.dequeueReusableCell(withClass: YHLiveShopViewCell.self) let cell = tableView.dequeueReusableCell(withClass: YHLiveShopViewCell.self)
model.flag = indexPath.row + 1
cell.dataSource = model cell.dataSource = model
cell.buyEvent = { [weak self] in
self?.buyData?(indexPath.row)
}
return cell return cell
} }
...@@ -218,7 +223,10 @@ class YHLiveShopViewCell: UITableViewCell { ...@@ -218,7 +223,10 @@ class YHLiveShopViewCell: UITableViewCell {
var subPriceLabel: UILabel! var subPriceLabel: UILabel!
var flagLabel: UILabel! var flagLabel: UILabel!
var buyButton: UIButton! var buyButton: UIButton!
var addButton: UIButton! //var addButton: UIButton!
// var addEvent: (() -> Void)?
var buyEvent: (() -> Void)?
var dataSource: YHLiveGoodsItem = YHLiveGoodsItem() { var dataSource: YHLiveGoodsItem = YHLiveGoodsItem() {
didSet { didSet {
...@@ -234,6 +242,7 @@ class YHLiveShopViewCell: UITableViewCell { ...@@ -234,6 +242,7 @@ class YHLiveShopViewCell: UITableViewCell {
priceLabel.attributed.text = a + b priceLabel.attributed.text = a + b
let c: ASAttributedString = .init("\(dataSource.price)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor(hex:0x8993a2)), .strikethrough(.single)) let c: ASAttributedString = .init("\(dataSource.price)", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor(hex:0x8993a2)), .strikethrough(.single))
subPriceLabel.attributed.text = c subPriceLabel.attributed.text = c
flagLabel.text = "\(dataSource.flag)"
} }
} }
override func awakeFromNib() { override func awakeFromNib() {
...@@ -305,9 +314,6 @@ class YHLiveShopViewCell: UITableViewCell { ...@@ -305,9 +314,6 @@ class YHLiveShopViewCell: UITableViewCell {
priceLabel = { priceLabel = {
let view = UILabel() let view = UILabel()
// let a: ASAttributedString = .init("¥", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor.mainTextColor))
// let b: ASAttributedString = .init("61000", .font(UIFont.PFSC_R(ofSize: 20)),.foreground(UIColor.mainTextColor))
// view.attributed.text = a + b
return view return view
}() }()
contentView.addSubview(priceLabel) contentView.addSubview(priceLabel)
...@@ -320,8 +326,6 @@ class YHLiveShopViewCell: UITableViewCell { ...@@ -320,8 +326,6 @@ class YHLiveShopViewCell: UITableViewCell {
subPriceLabel = { subPriceLabel = {
let view = UILabel() let view = UILabel()
// let c: ASAttributedString = .init("¥61000", .font(UIFont.PFSC_R(ofSize: 14)),.foreground(UIColor(hex:0x8993a2)), .strikethrough(.single))
// view.attributed.text = c
return view return view
}() }()
contentView.addSubview(subPriceLabel) contentView.addSubview(subPriceLabel)
...@@ -334,7 +338,6 @@ class YHLiveShopViewCell: UITableViewCell { ...@@ -334,7 +338,6 @@ class YHLiveShopViewCell: UITableViewCell {
flagLabel = { flagLabel = {
let label = UILabel() let label = UILabel()
label.text = "1"
label.textAlignment = .center label.textAlignment = .center
label.textColor = .white label.textColor = .white
label.font = UIFont.PFSC_M(ofSize: 10) label.font = UIFont.PFSC_M(ofSize: 10)
...@@ -366,28 +369,30 @@ class YHLiveShopViewCell: UITableViewCell { ...@@ -366,28 +369,30 @@ class YHLiveShopViewCell: UITableViewCell {
make.height.equalTo(28) make.height.equalTo(28)
} }
addButton = { // addButton = {
let button = UIButton(type: .custom) // let button = UIButton(type: .custom)
button.backgroundColor = UIColor(hex: 0xebf0f9) // button.backgroundColor = UIColor(hex: 0xebf0f9)
button.setImage(UIImage(named: "live_shop_add"), for: .normal) // button.setImage(UIImage(named: "live_shop_add"), for: .normal)
button.contentHorizontalAlignment = .center // button.contentHorizontalAlignment = .center
button.addTarget(self, action: #selector(add), for: .touchUpInside) // button.addTarget(self, action: #selector(add), for: .touchUpInside)
return button // return button
}() // }()
contentView.addSubview(addButton) // contentView.addSubview(addButton)
addButton.snp.makeConstraints { make in // addButton.snp.makeConstraints { make in
make.right.equalTo(-88) // make.right.equalTo(-88)
make.width.equalTo(46) // make.width.equalTo(46)
make.bottom.equalTo(centerImageView.snp.bottom) // make.bottom.equalTo(centerImageView.snp.bottom)
make.height.equalTo(28) // make.height.equalTo(28)
} // }
} }
@objc func add() { // @objc func add() {
//YHHUD.flash(message: "已加入购物车") // addEvent?()
} // //YHHUD.flash(message: "已加入购物车")
// }
@objc func buy() { @objc func buy() {
buyEvent?()
//YHHUD.flash(message: "已买") //YHHUD.flash(message: "已买")
} }
} }
...@@ -19,6 +19,8 @@ class YHLiveSalesViewModel: YHBaseViewModel { ...@@ -19,6 +19,8 @@ class YHLiveSalesViewModel: YHBaseViewModel {
// 获取环信Token信息 // 获取环信Token信息
var huanXinTokenModel: YHHuanXinTokenModel? var huanXinTokenModel: YHHuanXinTokenModel?
// 快速生成订单
var orderModel: YHLiveCreateOrderModel?
} }
extension YHLiveSalesViewModel { extension YHLiveSalesViewModel {
...@@ -175,30 +177,35 @@ extension YHLiveSalesViewModel { ...@@ -175,30 +177,35 @@ extension YHLiveSalesViewModel {
callback(false, err) callback(false, err)
} }
} }
func generateToken(channelName: String, uid: UInt = 0, success: @escaping (String?) -> Void) { /*
guard let certificate = YhConstant.AgoraRtcKit.certificate, !certificate.isEmpty else { 注册环信用户 "source": 0, // 1直播 2 录播
success(nil) "source_id": 0, // 直播或录播id
return "product": {
} "id": 0
let params = ["appCertificate": certificate, }
"appId": YhConstant.AgoraRtcKit.appId, */
"channelName": channelName, func createOrder(source: Int, sourceId: Int, productId: Int, callBackBlock: @escaping (_ orderModel: YHLiveCreateOrderModel?, _ error: YHErrorModel?) -> Void) {
"expire": 900, let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.createOrder
"src": "iOS", let product: [String: Int] = ["id": productId]
"ts": "".timeStamp, let params: [String: Any] = ["source": source, "source_id": sourceId, "product": product]
"type": 1, _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, _ in
"uid": "\(uid)"] as [String: Any]
let strUrl = "https://toolbox.bj2.agoralab.co/v1/token/generate"
_ = YHNetRequest.postRequest(url: strUrl, params: params) { response, code in
// 1. json字符串 转 对象 // 1. json字符串 转 对象
if let dict = response.data?.peel as? [String: String] { if json.code == 200 {
let token = dict["token"] guard let dic = json.data?.peel as? [String: Any], let resultModel = YHLiveCreateOrderModel.deserialize(from: dic) else {
success(token) let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(nil, err)
return
}
self?.orderModel = resultModel
callBackBlock(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(nil, err)
} }
success(nil)
} failBlock: { err in } failBlock: { err in
success(nil) callBackBlock(nil, err)
} }
} }
} }
......
...@@ -275,7 +275,6 @@ extension YhConstant { ...@@ -275,7 +275,6 @@ extension YhConstant {
struct AgoraRtcKit { struct AgoraRtcKit {
static let appId: String = "f1da9c5b9fb946148761278273f43a14" static let appId: String = "f1da9c5b9fb946148761278273f43a14"
static let certificate: String? = "1776134c2dcb4d60bc3d1983fef02212"
} }
// MARK: - 通知相关 名称 // MARK: - 通知相关 名称
......
...@@ -680,6 +680,8 @@ class YHAllApiName { ...@@ -680,6 +680,8 @@ class YHAllApiName {
static let leaveLiveRoom = "super-app/live/app-live-exit" static let leaveLiveRoom = "super-app/live/app-live-exit"
// 进入直播间--需求登录 // 进入直播间--需求登录
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"
} }
struct AIChat { struct AIChat {
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "live_icon_pause@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_icon_pause@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "live_icon_play@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_icon_play@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "live_msg_tips_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_msg_tips_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "live_slider_thumb@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_slider_thumb@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "live_time_separator@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "live_time_separator@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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