Move record button to front of toolbar for visibility
This commit is contained in:
parent
8af1140b06
commit
5960c5f7c8
@ -313,6 +313,13 @@ struct ControlToolbar: View {
|
||||
|
||||
// 按钮行
|
||||
HStack(spacing: 10) {
|
||||
// 录制(放最前面,更显眼)
|
||||
TB(icon: bridge.screenRecorder.isRecording ? "stop.circle.fill" : "record.circle") {
|
||||
bridge.toggleRecording(); onTouch()
|
||||
}
|
||||
|
||||
Divider().frame(height: 20).padding(.horizontal, 4)
|
||||
|
||||
TB(icon: "folder") { bridge.openFileDialog(); onTouch() }
|
||||
TB(icon: "link") { bridge.showURLDialog = true; onTouch() }
|
||||
TB(icon: "qrcode.viewfinder") { bridge.showQRScannerWindow(); onTouch() }
|
||||
@ -356,13 +363,6 @@ struct ControlToolbar: View {
|
||||
|
||||
// 播放列表
|
||||
TB(icon: "list.bullet") { bridge.togglePlaylistWindow(); onTouch() }
|
||||
|
||||
Divider().frame(height: 20).padding(.horizontal, 4)
|
||||
|
||||
// 录制
|
||||
TB(icon: bridge.screenRecorder.isRecording ? "stop.circle.fill" : "record.circle") {
|
||||
bridge.toggleRecording(); onTouch()
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
|
||||
@ -148,6 +148,7 @@ final class PlayerBridge: ObservableObject {
|
||||
guard index >= 0 && index < queue.count else { return }
|
||||
currentIndex = index
|
||||
let item = queue[index]
|
||||
print("[MiniPlayer] playIndex(\(index)): \(item.url.absoluteString)")
|
||||
|
||||
// 先清除旧的 KVO,避免野指针
|
||||
itemStatusObserver?.invalidate()
|
||||
@ -157,6 +158,7 @@ final class PlayerBridge: ObservableObject {
|
||||
player.replaceCurrentItem(with: playerItem)
|
||||
player.play()
|
||||
isPlaying = true
|
||||
print("[MiniPlayer] player.play() called, rate=\(player.rate)")
|
||||
|
||||
cachedDuration = 0
|
||||
progressRatio = 0
|
||||
@ -165,6 +167,7 @@ final class PlayerBridge: ObservableObject {
|
||||
|
||||
// KVO 可能从非主线程回调,用 DispatchQueue.main.async
|
||||
itemStatusObserver = playerItem.observe(\.status, options: [.new]) { [weak self] pi, _ in
|
||||
print("[MiniPlayer] KVO status changed: \(pi.status.rawValue), error=\(pi.error?.localizedDescription ?? "none")")
|
||||
if pi.status == .readyToPlay {
|
||||
DispatchQueue.main.async { self?.loadDuration(pi) }
|
||||
}
|
||||
@ -373,9 +376,11 @@ final class PlayerBridge: ObservableObject {
|
||||
}
|
||||
|
||||
func addURL(_ urlString: String) {
|
||||
print("[MiniPlayer] addURL called: \(urlString)")
|
||||
guard let url = URL(string: urlString) else { showToast(L.invalidURL); return }
|
||||
let name = url.lastPathComponent.isEmpty ? (url.host ?? urlString) : url.lastPathComponent
|
||||
let type = urlString.contains(".m3u8") ? "stream" : "url"
|
||||
print("[MiniPlayer] Adding item: name=\(name), type=\(type)")
|
||||
addItem(url: url, name: name, type: type)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user