Slide 13
Slide 13 text
case .playButtonTapped:
switch state.mode {
case .notPlaying:
state.mode = .playing(progress: state.time / state.duration)
return .run { [
url = state.url,
time = state.time,
playSpeed = state.playSpeed,
isLoop = state.isLooping
] send in
await send(.delegate(.playbackStarted))
async let playAudio: Void = send(
.audioPlayerClient(TaskResult {
try await self.audioPlayer.play(url, time, playSpeed, isLoop) }, .aut
)
for await _ in self.clock.timer(interval: .milliseconds(500)) {
let time = try await self.audioPlayer.getCurrentTime()
await send(.timerUpdated(time))
}
await playAudio
}.cancellable(id: CancelID.play, cancelInFlight: true)
Ի࠶ੜػೳͷྲྀΕ
1.࠶ੜঢ়ଶͷมߋ