@lls/lls-audio 0.0.7 → 0.0.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lls/lls-audio",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "main": "index.js",
5
5
  "devDependencies": {
6
6
  "@kadira/storybook": "^2.21.0",
package/player/Audio.js CHANGED
@@ -45,6 +45,10 @@ var Player = function (_Component) {
45
45
  return _this.setStateWithCallback({ currentRange: currentRange }, _this.onAudioUpdate);
46
46
  };
47
47
 
48
+ _this.getCurrentRange = function () {
49
+ return _this.state.currentRange;
50
+ };
51
+
48
52
  _this.setSpeed = function () {
49
53
  var speed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
50
54
 
@@ -16,7 +16,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
16
16
 
17
17
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
18
18
 
19
- var RESOLUTION = 1;
19
+ var RESOLUTION = 2;
20
20
  var colorScheme = ['#888', '#e51400'];
21
21
 
22
22
  var chunks = function chunks(arr, chunkSize) {
@@ -97,7 +97,7 @@ var _initialiseProps = function _initialiseProps() {
97
97
 
98
98
  // Duration and step calculation
99
99
  var maxDuration = totalTime || waveform.duration;
100
- var levelStep = maxWidth / maxDuration;
100
+ var levelStep = Math.ceil(waveform.max.length / maxWidth) * RESOLUTION;
101
101
 
102
102
  // Range positions
103
103
  //@todo: this range stuff should not be here. Waveform should just be passed an array of colors and ranges
@@ -105,7 +105,7 @@ var _initialiseProps = function _initialiseProps() {
105
105
  var endX = range ? range.endTime / maxDuration * maxWidth : maxDuration;
106
106
 
107
107
  // Split data into chunks per level
108
- var maxLevelChunks = chunks(waveform.max, Math.floor(pixels_per_second));
108
+ var maxLevelChunks = chunks(waveform.max, levelStep);
109
109
 
110
110
  // Calculate average for each level + highest average
111
111
 
@@ -127,7 +127,7 @@ var _initialiseProps = function _initialiseProps() {
127
127
 
128
128
  _this2.ctx.clearRect(0, 0, maxWidth, maxHeight);
129
129
  averages.forEach(function (average, i) {
130
- var x = i * levelStep;
130
+ var x = i * RESOLUTION;
131
131
  var h = average * (maxHeight / highestAverage);
132
132
 
133
133
  var color = x >= startX && x <= endX ? colorScheme[1] : colorScheme[0];
package/player/index.js CHANGED
@@ -76,6 +76,14 @@ var Player = function (_Component) {
76
76
 
77
77
  var _this = _possibleConstructorReturn(this, (Player.__proto__ || Object.getPrototypeOf(Player)).call(this));
78
78
 
79
+ _this.getCurrentRange = function () {
80
+ return _this.refs.audio.getCurrentRange();
81
+ };
82
+
83
+ _this.setRange = function (range) {
84
+ return _this.refs.audio.setRange(range);
85
+ };
86
+
79
87
  _this.state = { waveform: false, loading: true, containerWidth: 0 };
80
88
  _this.setContainerWidth = (0, _utils.debounce)(_this.setContainerWidth.bind(_this), 500);
81
89
  _this.onKeyPress = _this.onKeyPress.bind(_this);
package/stories/player.js CHANGED
@@ -15,7 +15,7 @@ var _player2 = _interopRequireDefault(_player);
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
 
17
17
  var PlayerExample = function PlayerExample() {
18
- return _react2.default.createElement(_player2.default, { url: 'cranberries_zombie.mp3' });
18
+ return _react2.default.createElement(_player2.default, { url: 'http://lls-media-public.s3.amazonaws.com/upload/LeLivreScolaire/p15vcjbl4lvpl9l7g8ov8ammh1.mp3' });
19
19
  };
20
20
 
21
21
  exports.default = PlayerExample;