From 5960c5f7c8386f65ac649c7352e0628e39064723 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 24 Jun 2026 19:45:36 +0800 Subject: [PATCH] Move record button to front of toolbar for visibility --- Sources/MiniPlayerApp.swift | 14 +++++++------- Sources/PlayerBridge.swift | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Sources/MiniPlayerApp.swift b/Sources/MiniPlayerApp.swift index 0e3abc2..e88a43d 100644 --- a/Sources/MiniPlayerApp.swift +++ b/Sources/MiniPlayerApp.swift @@ -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) diff --git a/Sources/PlayerBridge.swift b/Sources/PlayerBridge.swift index da021e0..393a3e3 100644 --- a/Sources/PlayerBridge.swift +++ b/Sources/PlayerBridge.swift @@ -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) }