forked from dmrschmidt/DSWaveformImage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WaveformImageViewUI.swift
37 lines (30 loc) · 1.06 KB
/
WaveformImageViewUI.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import DSWaveformImage
import Foundation
import SwiftUI
public struct WaveformImageViewUI: UIViewRepresentable {
let audioURL: URL
let configuration: Waveform.Configuration
public init(audioURL: URL, configuration: Waveform.Configuration) {
self.audioURL = audioURL
self.configuration = configuration
}
public func makeCoordinator() -> Coordinator {
Coordinator()
}
public func makeUIView(context: Context) -> UIView {
let waveformView = WaveformImageView(frame: .zero)
waveformView.configuration = configuration
waveformView.waveformAudioURL = audioURL
context.coordinator.waveformView = waveformView
return waveformView
}
public func updateUIView(_ uiView: UIView, context: Context) {
let waveformView = context.coordinator.waveformView!
waveformView.configuration = configuration
waveformView.waveformAudioURL = audioURL
}
public class Coordinator: NSObject {
var waveformView: WaveformImageView!
override init() {}
}
}