You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FDWaveformView is an easy way to display an audio waveform in your app. It is a nice visualization to show a playing audio file or to select a position in a file.
3
+
FDWaveformView displays audio waveforms in Swift apps so users can preview audio, scrub, and pick positions with ease.
4
4
5
-
Usage
6
-
-----
5
+
## Usage
7
6
8
-
To use it, add an `FDWaveformView`using Interface Builder or programmatically and then just load your audio as per this example. Note: if your audio file does not have file extension, see <ahref="https://stackoverflow.com/questions/9290972/is-it-possible-to-make-avurlasset-work-without-a-file-extension">this SO question</a>.
7
+
Add an `FDWaveformView`in Interface Builder or programmatically, then load audio. If your file is missing an extension, see the [Stack Overflow answer on AVURLAsset without extensions](https://stackoverflow.com/questions/9290972/is-it-possible-to-make-avurlasset-work-without-a-file-extension).
9
8
10
9
```swift
11
10
let thisBundle =Bundle(for: type(of: self))
12
11
let url = thisBundle.url(forResource: "Submarine", withExtension: "aiff")
- Antialiased waveforms draw extra pixels to avoid jagged edges.
67
+
- Autolayout-driven size changes trigger re-rendering to prevent pixelation.
68
+
- Supports iOS 12+ and Swift 5.
69
+
- Includes unit tests running on GitHub Actions.
70
+
71
+
## Installation
67
72
68
-
Creates **antialiased waveforms** by drawing more pixels than are seen on screen. Also, if you resize me (autolayout) I will render more detail if necessary to avoid pixelation.
73
+
Use Swift Package Manager: in Xcode choose File > Swift Packages > Add Package Dependency and point to this repository. Legacy installation options are available if needed.
69
74
70
-
Supports **iOS12+** and Swift 5.
75
+
## API
71
76
72
-
**Includes unit tests**, now running on GitHub Actions
77
+
Following is the complete API for this module:
78
+
79
+
-`FDWaveformView` (open class, subclass of `UIView`)
80
+
-`init()` (public init) default initializer
81
+
-`delegate: FDWaveformViewDelegate?` (open var, get/set) delegate for loading and rendering callbacks
82
+
-`audioURL: URL?` (open var, get/set) audio file to render asynchronously
83
+
-`totalSamples: Int` (open var, get) sample count of the loaded asset
84
+
-`highlightedSamples: CountableRange<Int>?` (open var, get/set) range tinted with `progressColor`
85
+
-`zoomSamples: CountableRange<Int>` (open var, get/set) range currently displayed
86
+
-`doesAllowScrubbing: Bool` (open var, get/set) enable tap and pan scrubbing
87
+
-`doesAllowStretch: Bool` (open var, get/set) enable pinch-to-zoom
88
+
-`doesAllowScroll: Bool` (open var, get/set) enable panning across the waveform
89
+
-`wavesColor: UIColor` (open var, get/set) tint for the base waveform image
90
+
-`progressColor: UIColor` (open var, get/set) tint for the highlighted waveform
91
+
-`loadingInProgress: Bool` (open var, get) indicates async load in progress
To build and run tests from the command line, first find an available simulator:
109
+
Find an available simulator:
77
110
78
111
```sh
79
112
xcrun simctl list devices available | grep iPhone
80
113
```
81
114
82
-
Then build and test using a simulator ID (replace the placeholder with an ID from the output above):
115
+
Build and test using a simulator ID from the output:
83
116
84
117
```sh
85
118
# Build the library
@@ -93,10 +126,6 @@ cd Example
93
126
xcodebuild build -scheme Example -destination 'id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
94
127
```
95
128
96
-
## Installation
97
-
98
-
Add this to your project using Swift Package Manager. In Xcode that is simply: File > Swift Packages > Add Package Dependency... and you're done. Alternative installations options are shown below for legacy projects.
99
-
100
129
## Contributing
101
130
102
-
* This project's layout is based on <https://github.com/fulldecent/swift6-module-template>
131
+
- This project's layout is based on <https://github.com/fulldecent/swift6-module-template>
0 commit comments