apm-react-audio-player 1.0.8 → 1.0.10

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 +34 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -93,16 +93,17 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
93
93
  _useState10 = _slicedToArray(_useState9, 2),
94
94
  isMuted = _useState10[0],
95
95
  setIsMuted = _useState10[1];
96
+ var isStream = audioRef.current && audioRef.current.currentSrc.includes('stream');
96
97
  React.useEffect(function () {
97
98
  if (currentTime === Number(duration)) {
98
- restart();
99
+ // restart()
99
100
  setIsFinishedPlaying(true);
100
101
  }
101
102
  }, [currentTime]);
102
103
  var onLoadedMetadata = function onLoadedMetadata() {
103
104
  var seconds = Math.floor(audioRef.current.duration);
104
105
  setDuration(seconds);
105
- if (!audioRef.current.currentSrc.includes('stream')) {
106
+ if (!isStream) {
106
107
  progressBarRef.current.max = seconds;
107
108
  }
108
109
  };
@@ -110,13 +111,15 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
110
111
  setCurrentTime(progressBarRef.current.value);
111
112
  };
112
113
  var whilePlaying = function whilePlaying() {
113
- progressBarRef.current.value = Math.floor(audioRef.current.currentTime);
114
+ if (!isStream) {
115
+ progressBarRef.current.value = Math.floor(audioRef.current.currentTime);
116
+ }
114
117
  progressBarRef.current.style.setProperty('--seek-before-width', "".concat(progressBarRef.current.value / duration * 100, "%"));
115
118
  updateCurrentTime();
116
119
 
117
120
  // when you reach the end of the song
118
- if (progressBarRef.current.value === duration) {
119
- restart();
121
+ if (!isStream && progressBarRef.current.value === duration) {
122
+ // restart()
120
123
  setIsFinishedPlaying(true);
121
124
  return;
122
125
  }
@@ -127,16 +130,20 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
127
130
  audioRef.current.pause();
128
131
  window.cancelAnimationFrame(animationRef.current);
129
132
  };
130
- var restart = function restart() {
131
- progressBarRef.current.value = 0;
132
- updateCurrentTime();
133
- pause();
134
- };
133
+
134
+ // const restart = () => {
135
+ // progressBarRef.current.value = 0
136
+ // updateCurrentTime()
137
+ // pause()
138
+ // }
139
+
135
140
  var play = function play() {
136
141
  setIsPlaying(true);
137
142
  setIsFinishedPlaying(false);
138
143
  audioRef.current.play();
139
- animationRef.current = window.requestAnimationFrame(whilePlaying);
144
+ if (!isStream) {
145
+ animationRef.current = window.requestAnimationFrame(whilePlaying);
146
+ }
140
147
  };
141
148
  var toggleMute = function toggleMute() {
142
149
  setIsMuted(!isMuted);
@@ -205,8 +212,14 @@ var Play = function Play() {
205
212
  className: "play",
206
213
  height: "1em",
207
214
  width: "1em",
208
- xmlns: "http://www.w3.org/2000/svg"
209
- }, /*#__PURE__*/React__default.createElement("path", {
215
+ xmlns: "http://www.w3.org/2000/svg",
216
+ role: "img",
217
+ "aria-labelledby": "play playButton"
218
+ }, /*#__PURE__*/React__default.createElement("title", {
219
+ id: "play"
220
+ }, "Play"), /*#__PURE__*/React__default.createElement("desc", {
221
+ id: "playButton"
222
+ }, "Play Button"), /*#__PURE__*/React__default.createElement("path", {
210
223
  d: "M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"
211
224
  }));
212
225
  };
@@ -219,8 +232,14 @@ var Pause = function Pause() {
219
232
  viewBox: "0 0 448 512",
220
233
  height: "1em",
221
234
  width: "1em",
222
- xmlns: "http://www.w3.org/2000/svg"
223
- }, /*#__PURE__*/React__default.createElement("path", {
235
+ xmlns: "http://www.w3.org/2000/svg",
236
+ role: "img",
237
+ "aria-labelledby": "pause pauseButton"
238
+ }, /*#__PURE__*/React__default.createElement("title", {
239
+ id: "pause"
240
+ }, "Pause"), /*#__PURE__*/React__default.createElement("desc", {
241
+ id: "pauseButton"
242
+ }, "Pause Button"), /*#__PURE__*/React__default.createElement("path", {
224
243
  d: "M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z"
225
244
  }));
226
245
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apm-react-audio-player",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "author": "Jason Phan <jphan@mpr.org>",
5
5
  "license": "MIT",
6
6
  "private": false,