apm-react-audio-player 1.0.11 → 1.0.12

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.
Files changed (2) hide show
  1. package/dist/index.js +40 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -167,16 +167,18 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
167
167
  setCurrentTime(progressBarRef.current.value);
168
168
  progressBarRef.current.style.setProperty('--seek-before-width', "".concat(progressBarRef.current.value / duration * 100, "%"));
169
169
  };
170
- var timeTravel = function timeTravel(newTime) {
171
- progressBarRef.current.value = newTime;
170
+ var changeRange = function changeRange() {
171
+ audioRef.current.currentTime = progressBarRef.current.value;
172
172
  updateCurrentTime();
173
173
  changePlayerCurrentTime();
174
174
  };
175
- var backThirty = function backThirty() {
176
- timeTravel(Number(progressBarRef.current.value) - 30);
175
+ var rewindControl = function rewindControl() {
176
+ progressBarRef.current.value = Number(progressBarRef.current.value) - 15;
177
+ changeRange();
177
178
  };
178
- var forwardThirty = function forwardThirty() {
179
- timeTravel(Number(progressBarRef.current.value) + 30);
179
+ var forwardControl = function forwardControl() {
180
+ progressBarRef.current.value = Number(progressBarRef.current.value) + 15;
181
+ changeRange();
180
182
  };
181
183
  var volumeControl = function volumeControl(e) {
182
184
  var value = e.target.value;
@@ -205,8 +207,8 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
205
207
  calculateTime: calculateTime,
206
208
  togglePlaying: togglePlaying,
207
209
  changePlayerCurrentTime: changePlayerCurrentTime,
208
- backThirty: backThirty,
209
- forwardThirty: forwardThirty,
210
+ rewindControl: rewindControl,
211
+ forwardControl: forwardControl,
210
212
  play: play,
211
213
  pause: pause,
212
214
  isPlaying: isPlaying,
@@ -214,9 +216,9 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
214
216
  currentTime: currentTime,
215
217
  duration: duration,
216
218
  volumeCtrl: volumeCtrl,
219
+ isMuted: isMuted,
217
220
  volumeControl: volumeControl,
218
221
  toggleMute: toggleMute,
219
- isMuted: isMuted,
220
222
  formatCalculateTime: formatCalculateTime
221
223
  };
222
224
  };
@@ -285,7 +287,9 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
285
287
  volumeControl = props.volumeControl,
286
288
  toggleMute = props.toggleMute,
287
289
  isMuted = props.isMuted,
288
- formatCalculateTime = props.formatCalculateTime;
290
+ formatCalculateTime = props.formatCalculateTime,
291
+ rewindControl = props.rewindControl,
292
+ forwardControl = props.forwardControl;
289
293
  var audioDuration = duration && !isNaN(duration) && calculateTime(duration);
290
294
  var formatDuration = duration && !isNaN(duration) && audioDuration && formatCalculateTime(audioDuration);
291
295
  return audioSrc && /*#__PURE__*/React__default.createElement("div", {
@@ -335,13 +339,27 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
335
339
  className: "player-volume-label"
336
340
  }, "Volume")), /*#__PURE__*/React__default.createElement("div", {
337
341
  className: "player-controls"
338
- }, /*#__PURE__*/React__default.createElement("div", {
342
+ }, !isLive && /*#__PURE__*/React__default.createElement("div", {
343
+ className: "player-backward-forward-controls"
344
+ }, /*#__PURE__*/React__default.createElement("button", {
345
+ onClick: rewindControl
346
+ }, /*#__PURE__*/React__default.createElement("img", {
347
+ src: "/img/icon-rewind-15.svg",
348
+ alt: "Backward 15 seconds"
349
+ }))), /*#__PURE__*/React__default.createElement("div", {
339
350
  className: "".concat(isPlaying ? 'is-playing' : '', " player-btn-play-pause-outer")
340
351
  }, /*#__PURE__*/React__default.createElement("button", {
341
352
  onClick: togglePlaying,
342
353
  className: playBtnClass,
343
354
  style: customStyles && customStyles.playPause
344
- }, isPlaying ? /*#__PURE__*/React__default.createElement(Pause, null) : /*#__PURE__*/React__default.createElement(Play, null)))), !isLive && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
355
+ }, isPlaying ? /*#__PURE__*/React__default.createElement(Pause, null) : /*#__PURE__*/React__default.createElement(Play, null))), !isLive && /*#__PURE__*/React__default.createElement("div", {
356
+ className: "player-backward-forward-controls"
357
+ }, /*#__PURE__*/React__default.createElement("button", {
358
+ onClick: forwardControl
359
+ }, /*#__PURE__*/React__default.createElement("img", {
360
+ src: "/img/icon-forward-15.svg",
361
+ alt: "Forward 15 seconds"
362
+ })))), !isLive && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
345
363
  className: "player-timeline"
346
364
  }, /*#__PURE__*/React__default.createElement("input", {
347
365
  type: "range",
@@ -392,22 +410,26 @@ var ReactAudioPlayer = function ReactAudioPlayer(props) {
392
410
  volumeControl = _useAudioPlayer.volumeControl,
393
411
  toggleMute = _useAudioPlayer.toggleMute,
394
412
  isMuted = _useAudioPlayer.isMuted,
395
- formatCalculateTime = _useAudioPlayer.formatCalculateTime;
413
+ formatCalculateTime = _useAudioPlayer.formatCalculateTime,
414
+ rewindControl = _useAudioPlayer.rewindControl,
415
+ forwardControl = _useAudioPlayer.forwardControl;
396
416
  return /*#__PURE__*/React__default.createElement(ReactAudioPlayerInner, _extends({}, props, {
397
417
  audioPlayerRef: audioPlayerRef,
398
418
  progressBarRef: progressBarRef,
419
+ isPlaying: isPlaying,
420
+ isMuted: isMuted,
421
+ currentTime: currentTime,
422
+ duration: duration,
399
423
  customStyles: customStyles,
400
424
  onLoadedMetadata: onLoadedMetadata,
401
425
  calculateTime: calculateTime,
402
426
  togglePlaying: togglePlaying,
403
427
  changePlayerCurrentTime: changePlayerCurrentTime,
404
- isPlaying: isPlaying,
405
- currentTime: currentTime,
406
- duration: duration,
407
428
  volumeControl: volumeControl,
408
429
  toggleMute: toggleMute,
409
- isMuted: isMuted,
410
- formatCalculateTime: formatCalculateTime
430
+ formatCalculateTime: formatCalculateTime,
431
+ rewindControl: rewindControl,
432
+ forwardControl: forwardControl
411
433
  }));
412
434
  };
413
435
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apm-react-audio-player",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "author": "Jason Phan <jphan@mpr.org>",
5
5
  "license": "MIT",
6
6
  "private": false,