Advance UIKit rewrite with AMap integration and core UI modules.
Integrate高德 SDK with simulator-safe build flags, add map views for operating area and punch points, refactor main tabs and key feature screens to UIKit with Diffable lists, and document Swift concurrency defaults in AGENTS.md. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -10,10 +10,12 @@ import Foundation
|
||||
|
||||
/// 直播播放地址解析器,避免把 RTMP 推流地址误当作播放地址。
|
||||
enum LivePlaybackURLResolver {
|
||||
/// playable链接相关逻辑。
|
||||
static func playableURL(from live: LiveEntity) -> URL? {
|
||||
playableURL(from: live.playbackURLCandidates)
|
||||
}
|
||||
|
||||
/// playable链接相关逻辑。
|
||||
static func playableURL(from candidates: [String]) -> URL? {
|
||||
for candidate in candidates {
|
||||
if let url = playableURL(from: candidate) {
|
||||
@ -23,6 +25,7 @@ enum LivePlaybackURLResolver {
|
||||
return nil
|
||||
}
|
||||
|
||||
/// playable链接相关逻辑。
|
||||
static func playableURL(from rawValue: String) -> URL? {
|
||||
let value = rawValue.liveTrimmed
|
||||
guard !value.isEmpty, let url = URL(string: value) else { return nil }
|
||||
@ -65,6 +68,7 @@ final class LivePlaybackViewModel {
|
||||
return false
|
||||
}
|
||||
|
||||
/// 初始化实例。
|
||||
init(live: LiveEntity? = nil, urlString: String? = nil) {
|
||||
if let live {
|
||||
load(live: live)
|
||||
@ -73,14 +77,17 @@ final class LivePlaybackViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// 加载数据。
|
||||
func load(live: LiveEntity) {
|
||||
load(url: LivePlaybackURLResolver.playableURL(from: live))
|
||||
}
|
||||
|
||||
/// 加载数据。
|
||||
func load(urlString: String) {
|
||||
load(url: LivePlaybackURLResolver.playableURL(from: urlString))
|
||||
}
|
||||
|
||||
/// play 业务逻辑。
|
||||
func play() {
|
||||
guard let url = playableURL else { return }
|
||||
if player == nil {
|
||||
@ -90,12 +97,14 @@ final class LivePlaybackViewModel {
|
||||
state = .playing(url)
|
||||
}
|
||||
|
||||
/// pause 业务逻辑。
|
||||
func pause() {
|
||||
guard let url = playableURL else { return }
|
||||
player?.pause()
|
||||
state = .ready(url)
|
||||
}
|
||||
|
||||
/// 刷新。
|
||||
func reload() {
|
||||
guard let url = playableURL else { return }
|
||||
releasePlayer()
|
||||
@ -103,6 +112,7 @@ final class LivePlaybackViewModel {
|
||||
state = .ready(url)
|
||||
}
|
||||
|
||||
/// release 业务逻辑。
|
||||
func release() {
|
||||
releasePlayer()
|
||||
if let url = playableURL {
|
||||
@ -112,6 +122,7 @@ final class LivePlaybackViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// 加载数据。
|
||||
private func load(url: URL?) {
|
||||
releasePlayer()
|
||||
guard let url else {
|
||||
@ -124,6 +135,7 @@ final class LivePlaybackViewModel {
|
||||
state = .ready(url)
|
||||
}
|
||||
|
||||
/// releasePlayer相关逻辑。
|
||||
private func releasePlayer() {
|
||||
player?.pause()
|
||||
player = nil
|
||||
|
||||
Reference in New Issue
Block a user