Skip to content

Commit

Permalink
Refresh waveform when a new URL is set, Issue AudioKit#89
Browse files Browse the repository at this point in the history
  • Loading branch information
mahal committed Jun 12, 2024
1 parent 83bacdb commit d35d609
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,26 @@ public struct AudioFileWaveform: View {
}

public var body: some View {
Group {
let group = Group {
if viewModel.rmsValues.count > 2 {
AudioWaveform(rmsVals: viewModel.rmsValues)
.fill(color)
} else {
AudioWaveform(rmsVals: viewModel.rmsValues)
.stroke(color)
}
}.onAppear {
viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow)
}
if #available(iOS 17.0, *) {
group.onChange(of:url) {
viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow)
}
.onAppear {
viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow)
}
} else {
group.onAppear {
viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow)
}
}
}
}
Expand Down

0 comments on commit d35d609

Please sign in to comment.