wavesurfer-rails 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +95 -16
- data/lib/wavesurfer/rails/version.rb +1 -1
- data/wavesurfer-rails.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d583a26ff8fe19758090aa446c2888af1f3578c6
|
4
|
+
data.tar.gz: 01700088d6050b7b858d6cfbf9bce1098c9dc5cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49608f4c19dd4cbbe3efabaa5de60f4d02142fe436206a0a1a62150e73d1840fa2f5bb9306bd8b0c5d81ea6b03ffaba60a4db79e07549e7ba2028945412339a0
|
7
|
+
data.tar.gz: f32462fd869f0a0d02eb2d326cf1b204b5f3a4fa1637964fc58cd437dc6296622f6c19630449ffec1cb93692e2042aa362f9cdbc4386e13edf4103580342a0f9
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# Wavesurfer
|
1
|
+
# Wavesurfer-rails
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
[Wavesurfer-js](http://wavesurfer-js.org/)
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -16,24 +14,105 @@ And then execute:
|
|
16
14
|
|
17
15
|
$ bundle
|
18
16
|
|
19
|
-
|
17
|
+
In `app/assets/javascripts/application.js` put the following:
|
18
|
+
|
19
|
+
```javascript
|
20
|
+
//= require wavesurfer
|
21
|
+
```
|
22
|
+
|
23
|
+
If you want the wavesurfer plugins:
|
20
24
|
|
21
|
-
|
25
|
+
```javascript
|
26
|
+
//= require wavesurfer-plugins
|
27
|
+
```
|
22
28
|
|
23
29
|
## Usage
|
24
30
|
|
25
|
-
|
31
|
+
From the wavesurfer documentation:
|
26
32
|
|
27
|
-
|
33
|
+
```javascript
|
34
|
+
var wavesurfer = Object.create(WaveSurfer);
|
28
35
|
|
29
|
-
|
36
|
+
wavesurfer.init({
|
37
|
+
container: document.querySelector('#wave'),
|
38
|
+
waveColor: 'violet',
|
39
|
+
progressColor: 'purple'
|
40
|
+
});
|
30
41
|
|
31
|
-
|
42
|
+
wavesurfer.on('ready', function () {
|
43
|
+
wavesurfer.play();
|
44
|
+
});
|
32
45
|
|
33
|
-
|
46
|
+
wavesurfer.load('example/media/demo.mp3');
|
47
|
+
```
|
34
48
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
49
|
+
## WaveSurfer Options
|
50
|
+
|
51
|
+
| option | type | default | description |
|
52
|
+
| --- | --- | --- | --- |
|
53
|
+
| `audioContext` | object | _none_ | Use your own previously initialized `AudioContext` or leave blank. |
|
54
|
+
| `audioRate` | float | `1` | Speed at which to play audio. Lower number is slower. |
|
55
|
+
| `backend` | string | `WebAudio` | `WebAudio` or `MediaElement`. In most cases you don't have to set this manually. `MediaElement` is a fallback for unsupported browsers. |
|
56
|
+
| `barWidth` | number | _none_ | If specified, the waveform will be drawn like this: ▁ ▂ ▇ ▃ ▅ ▂ |
|
57
|
+
| `container` | mixed | _none_ | CSS-selector or HTML-element where the waveform should be drawn. This is the only required parameter. |
|
58
|
+
| `cursorColor` | string | `#333` | The fill color of the cursor indicating the playhead position. |
|
59
|
+
| `cursorWidth` | integer | `1` | Measured in pixels. |
|
60
|
+
| `fillParent` | boolean | `true` | Whether to fill the entire container or draw only according to `minPxPerSec`. |
|
61
|
+
| `height` | integer | `128` | The height of the waveform. Measured in pixels. |
|
62
|
+
| `hideScrollbar` | boolean | `false` | Whether to hide the horizontal scrollbar when one would normally be shown. |
|
63
|
+
| `interact` | boolean | `true` | Whether the mouse interaction will be enabled at initialization. You can switch this parameter at any time later on. |
|
64
|
+
| `minPxPerSec` | integer | `50` | Minimum number of pixels per second of audio. |
|
65
|
+
| `normalize` | boolean | `false` | If `true`, normalize by the maximum peak instead of 1.0. |
|
66
|
+
| `pixelRatio` | integer | `window.devicePixelRatio` | Can be set to `1` for faster rendering. |
|
67
|
+
| `progressColor` | string | `#555` | The fill color of the part of the waveform behind the cursor. |
|
68
|
+
| `scrollParent` | boolean | `false` | Whether to scroll the container with a lengthy waveform. Otherwise the waveform is shrunk to the container width (see `fillParent`). |
|
69
|
+
| `skipLength` | float | `2` | Number of seconds to skip with the `skipForward()` and `skipBackward()` methods. |
|
70
|
+
| `waveColor` | string | `#999` | The fill color of the waveform after the cursor. |
|
71
|
+
|
72
|
+
## WaveSurfer Methods
|
73
|
+
|
74
|
+
All methods are intentionally public, but the most readily available are the following:
|
75
|
+
|
76
|
+
* `init(options)` – Initializes with the options listed above.
|
77
|
+
* `destroy()` – Removes events, elements and disconnects Web Audio nodes.
|
78
|
+
* `empty()` – Clears the waveform as if a zero-length audio is loaded.
|
79
|
+
* `getCurrentTime()` – Returns current progress in seconds.
|
80
|
+
* `getDuration()` – Returns the duration of an audio clip in seconds.
|
81
|
+
* `isPlaying()` – Returns true if currently playing, false otherwise.
|
82
|
+
* `load(url)` – Loads audio from URL via XHR. Returns XHR object.
|
83
|
+
* `loadBlob(url)` – Loads audio from a `Blob` or `File` object.
|
84
|
+
* `on(eventName, callback)` – Subscribes to an event. See [WaveSurfer Events](#wavesurfer-events) section below for a list.
|
85
|
+
* `un(eventName, callback)` – Unsubscribes from an event.
|
86
|
+
* `unAll()` – Unsubscribes from all events.
|
87
|
+
* `pause()` – Stops playback.
|
88
|
+
* `play([start[, end]])` – Starts playback from the current position. Optional `start` and `end` measured in seconds can be used to set the range of audio to play.
|
89
|
+
* `playPause()` – Plays if paused, pauses if playing.
|
90
|
+
* `seekAndCenter(progress)` – Seeks to a progress and centers view `[0..1]` (0 = beginning, 1 = end).
|
91
|
+
* `seekTo(progress)` – Seeks to a progress `[0..1]` (0=beginning, 1=end).
|
92
|
+
* `setFilter(filters)` - For inserting your own WebAudio nodes into the graph. See [Connecting Filters](#connecting-filters) below.
|
93
|
+
* `setPlaybackRate(rate)` – Sets the speed of playback (`0.5` is half speed, `1` is normal speed, `2` is double speed and so on).
|
94
|
+
* `setVolume(newVolume)` – Sets the playback volume to a new value `[0..1]` (0 = silent, 1 = maximum).
|
95
|
+
* `skip(offset)` – Skip a number of seconds from the current position (use a negative value to go backwards).
|
96
|
+
* `skipBackward()` - Rewind `skipLength` seconds.
|
97
|
+
* `skipForward()` - Skip ahead `skipLength` seconds.
|
98
|
+
* `stop()` – Stops and goes to the beginning.
|
99
|
+
* `toggleMute()` – Toggles the volume on and off.
|
100
|
+
* `toggleInteraction()` – Toggle mouse interaction.
|
101
|
+
* `toggleScroll()` – Toggles `scrollParent`.
|
102
|
+
* `zoom(pxPerSec)` – Horiontally zooms the waveform in and out. The
|
103
|
+
parameter is a number of horizontal pixels per second of audio. It
|
104
|
+
also changes the parameter `minPxPerSec` and enables the
|
105
|
+
`scrollParent` option.
|
106
|
+
|
107
|
+
## Credits
|
108
|
+
|
109
|
+
Initial idea by [Alex Khokhulin](https://github.com/xoxulin). Many
|
110
|
+
thanks to
|
111
|
+
[the awesome contributors](https://github.com/katspaugh/wavesurfer.js/contributors)!
|
112
|
+
|
113
|
+
## License
|
114
|
+
|
115
|
+

|
116
|
+
|
117
|
+
This work is licensed under a
|
118
|
+
[Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/deed.en_US).
|
data/wavesurfer-rails.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Taylor Daugherty"]
|
10
10
|
spec.email = ["mdaugherty6@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{}
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{http://wavesurfer-js.org/}
|
13
|
+
spec.description = %q{Wavesurfer.js for the rails asset pipeline.}
|
14
14
|
spec.homepage = "https://taylord.io"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wavesurfer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Daugherty
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description:
|
41
|
+
description: Wavesurfer.js for the rails asset pipeline.
|
42
42
|
email:
|
43
43
|
- mdaugherty6@gmail.com
|
44
44
|
executables: []
|
@@ -88,5 +88,5 @@ rubyforge_project:
|
|
88
88
|
rubygems_version: 2.4.8
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
|
-
summary:
|
91
|
+
summary: http://wavesurfer-js.org/
|
92
92
|
test_files: []
|