feat: add Chromecast playback support

This commit is contained in:
2026-10-13 17:31:37 +02:00
parent 74b4bfe6c1
commit bb777b0ecd
22 changed files with 3299 additions and 115 deletions
+48
View File
@@ -0,0 +1,48 @@
import SwiftUI
@MainActor
struct CastDeviceMenu: View {
@ObservedObject var model: PlayerModel
@ObservedObject private var discovery: CastDiscovery
var icon = true
init(model: PlayerModel, icon: Bool = true) {
self.model = model
self.discovery = model.castDiscovery
self.icon = icon
}
var body: some View {
Menu {
if let device = model.castDevice {
Text((model.castConnecting ? "Connecting to " : "Casting to ") + device.name)
Button(model.castConnecting ? "Cancel Casting" : "Play on This Mac") { model.stopCasting() }
Divider()
}
ForEach(discovery.devices) { device in
Button(device.name) { model.cast(to: device) }
.disabled(!model.canCast)
}
if discovery.devices.isEmpty {
Text("No Cast devices discovered")
}
if let error = discovery.error { Text(error) }
Divider()
Button("Find Cast Devices…") { discovery.start() }
} label: {
if icon {
Image(systemName: "tv.badge.wifi")
.font(.system(size: 14))
.frame(width: 24, height: 24)
} else {
Text("Cast to Device")
}
}
.menuStyle(.button)
.buttonStyle(.plain)
.menuIndicator(.hidden)
.fixedSize()
.accessibilityLabel("Cast to Device")
.help(model.castDevice.map { "Casting to " + $0.name } ?? "Cast to Device")
}
}