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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6d5207276b66fe5b32d975bd97a71e270d024fd
4
- data.tar.gz: 3e551455000ace906dcd2f624e759f8e0055c6b1
3
+ metadata.gz: d583a26ff8fe19758090aa446c2888af1f3578c6
4
+ data.tar.gz: 01700088d6050b7b858d6cfbf9bce1098c9dc5cf
5
5
  SHA512:
6
- metadata.gz: 8f2c2beae816567f43c7b798596af964922c0bef92c2798b03112ab73dd5de87cb24b31f8614ddc9c4f55ea902a691ccc9e4e46ef0bfe03816d56daa391384c4
7
- data.tar.gz: 6ee4250bafda4fdff04917e1e8c576436326f60a185bd5a1ddd3b7dfc95b2725c5c97aac291c2966e5f1b415c26cb6d9eaebef9a7e4b947cfb47d8e568f42bcd
6
+ metadata.gz: 49608f4c19dd4cbbe3efabaa5de60f4d02142fe436206a0a1a62150e73d1840fa2f5bb9306bd8b0c5d81ea6b03ffaba60a4db79e07549e7ba2028945412339a0
7
+ data.tar.gz: f32462fd869f0a0d02eb2d326cf1b204b5f3a4fa1637964fc58cd437dc6296622f6c19630449ffec1cb93692e2042aa362f9cdbc4386e13edf4103580342a0f9
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Wavesurfer::Rails
1
+ # Wavesurfer-rails
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wavesurfer/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- Or install it yourself as:
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
- $ gem install wavesurfer-rails
25
+ ```javascript
26
+ //= require wavesurfer-plugins
27
+ ```
22
28
 
23
29
  ## Usage
24
30
 
25
- TODO: Write usage instructions here
31
+ From the wavesurfer documentation:
26
32
 
27
- ## Development
33
+ ```javascript
34
+ var wavesurfer = Object.create(WaveSurfer);
28
35
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
36
+ wavesurfer.init({
37
+ container: document.querySelector('#wave'),
38
+ waveColor: 'violet',
39
+ progressColor: 'purple'
40
+ });
30
41
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+ wavesurfer.on('ready', function () {
43
+ wavesurfer.play();
44
+ });
32
45
 
33
- ## Contributing
46
+ wavesurfer.load('example/media/demo.mp3');
47
+ ```
34
48
 
35
- 1. Fork it ( https://github.com/[my-github-username]/wavesurfer-rails/fork )
36
- 2. Create your feature branch (`git checkout -b my-new-feature`)
37
- 3. Commit your changes (`git commit -am 'Add some feature'`)
38
- 4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create a new Pull Request
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
+ ![cc-by](http://i.creativecommons.org/l/by/3.0/88x31.png)
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).
@@ -1,5 +1,5 @@
1
1
  module Wavesurfer
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -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{Wavsurfer.js for the rails asset pipeline}
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.0
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: Wavsurfer.js for the rails asset pipeline
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: []