feat(demo): add Single/Loop play-mode buttons gated by isActivated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,22 @@ struct WrapperTestView: View {
|
|||||||
Button("unbind") { runUnbind() }
|
Button("unbind") { runUnbind() }
|
||||||
.buttonStyle(.bordered)
|
.buttonStyle(.bordered)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text("PlayMode")
|
||||||
|
.font(.caption)
|
||||||
|
Spacer()
|
||||||
|
if let mode = viewModel.deviceInfo?.loop {
|
||||||
|
Text(mode == .loop ? "循环" : "单播")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
Button("Single") { runSetPlayMode(.single) }
|
||||||
|
.buttonStyle(.bordered)
|
||||||
|
Button("Loop") { runSetPlayMode(.loop) }
|
||||||
|
.buttonStyle(.bordered)
|
||||||
|
}
|
||||||
|
.disabled(!viewModel.isActivated || isBusy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +412,22 @@ struct WrapperTestView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func runSetPlayMode(_ mode: PlayMode) {
|
||||||
|
isBusy = true
|
||||||
|
log("→ setPlayMode(\(mode == .loop ? "loop" : "single"), userId=\(userId))")
|
||||||
|
viewModel.sdk.setPlayMode(mode, userId: userId) { [self] result in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.isBusy = false
|
||||||
|
switch result {
|
||||||
|
case .success(let resp):
|
||||||
|
self.log("setPlayMode ✓ sn=\(resp.sn)", level: .success)
|
||||||
|
case .failure(let error):
|
||||||
|
self.log("setPlayMode ✗ \(error.localizedDescription)", level: .error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func runTransfer() {
|
private func runTransfer() {
|
||||||
isBusy = true
|
isBusy = true
|
||||||
log("→ transferMedia(\(fileUrl))")
|
log("→ transferMedia(\(fileUrl))")
|
||||||
|
|||||||
Reference in New Issue
Block a user