apm-react-audio-player 1.0.9 → 1.0.11
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/dist/index.js +69 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -183,6 +183,23 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
|
|
|
183
183
|
var volume = value / 100;
|
|
184
184
|
audioRef.current.volume = volume;
|
|
185
185
|
};
|
|
186
|
+
var formatCalculateTime = function formatCalculateTime(timeString) {
|
|
187
|
+
var toString = String(timeString);
|
|
188
|
+
if (toString.split(':').length === 3) {
|
|
189
|
+
var _toString$split = toString.split(':'),
|
|
190
|
+
_toString$split2 = _slicedToArray(_toString$split, 3),
|
|
191
|
+
hours = _toString$split2[0],
|
|
192
|
+
minutes = _toString$split2[1],
|
|
193
|
+
seconds = _toString$split2[2];
|
|
194
|
+
return "".concat(parseInt(hours), "hr ").concat(parseInt(minutes), "min ").concat(parseInt(seconds), "sec");
|
|
195
|
+
} else if (toString.split(':').length === 2) {
|
|
196
|
+
var _toString$split3 = toString.split(':'),
|
|
197
|
+
_toString$split4 = _slicedToArray(_toString$split3, 2),
|
|
198
|
+
_minutes = _toString$split4[0],
|
|
199
|
+
_seconds = _toString$split4[1];
|
|
200
|
+
return "".concat(parseInt(_minutes), "min ").concat(parseInt(_seconds), "sec");
|
|
201
|
+
}
|
|
202
|
+
};
|
|
186
203
|
return {
|
|
187
204
|
onLoadedMetadata: onLoadedMetadata,
|
|
188
205
|
calculateTime: calculateTime,
|
|
@@ -199,7 +216,8 @@ var useAudioPlayer = function useAudioPlayer(audioRef, progressBarRef, volumeCtr
|
|
|
199
216
|
volumeCtrl: volumeCtrl,
|
|
200
217
|
volumeControl: volumeControl,
|
|
201
218
|
toggleMute: toggleMute,
|
|
202
|
-
isMuted: isMuted
|
|
219
|
+
isMuted: isMuted,
|
|
220
|
+
formatCalculateTime: formatCalculateTime
|
|
203
221
|
};
|
|
204
222
|
};
|
|
205
223
|
|
|
@@ -212,8 +230,14 @@ var Play = function Play() {
|
|
|
212
230
|
className: "play",
|
|
213
231
|
height: "1em",
|
|
214
232
|
width: "1em",
|
|
215
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
216
|
-
|
|
233
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
234
|
+
role: "img",
|
|
235
|
+
"aria-labelledby": "play playButton"
|
|
236
|
+
}, /*#__PURE__*/React__default.createElement("title", {
|
|
237
|
+
id: "play"
|
|
238
|
+
}, "Play"), /*#__PURE__*/React__default.createElement("desc", {
|
|
239
|
+
id: "playButton"
|
|
240
|
+
}, "Play Button"), /*#__PURE__*/React__default.createElement("path", {
|
|
217
241
|
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"
|
|
218
242
|
}));
|
|
219
243
|
};
|
|
@@ -226,8 +250,14 @@ var Pause = function Pause() {
|
|
|
226
250
|
viewBox: "0 0 448 512",
|
|
227
251
|
height: "1em",
|
|
228
252
|
width: "1em",
|
|
229
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
230
|
-
|
|
253
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
254
|
+
role: "img",
|
|
255
|
+
"aria-labelledby": "pause pauseButton"
|
|
256
|
+
}, /*#__PURE__*/React__default.createElement("title", {
|
|
257
|
+
id: "pause"
|
|
258
|
+
}, "Pause"), /*#__PURE__*/React__default.createElement("desc", {
|
|
259
|
+
id: "pauseButton"
|
|
260
|
+
}, "Pause Button"), /*#__PURE__*/React__default.createElement("path", {
|
|
231
261
|
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"
|
|
232
262
|
}));
|
|
233
263
|
};
|
|
@@ -240,7 +270,6 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
240
270
|
|
|
241
271
|
var customStyles = props ? props.style : '';
|
|
242
272
|
var title = props.title,
|
|
243
|
-
description = props.description,
|
|
244
273
|
audioSrc = props.audioSrc,
|
|
245
274
|
volumeCtrl = props.volumeCtrl,
|
|
246
275
|
playBtnClass = props.playBtnClass,
|
|
@@ -255,7 +284,10 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
255
284
|
duration = props.duration,
|
|
256
285
|
volumeControl = props.volumeControl,
|
|
257
286
|
toggleMute = props.toggleMute,
|
|
258
|
-
isMuted = props.isMuted
|
|
287
|
+
isMuted = props.isMuted,
|
|
288
|
+
formatCalculateTime = props.formatCalculateTime;
|
|
289
|
+
var audioDuration = duration && !isNaN(duration) && calculateTime(duration);
|
|
290
|
+
var formatDuration = duration && !isNaN(duration) && audioDuration && formatCalculateTime(audioDuration);
|
|
259
291
|
return audioSrc && /*#__PURE__*/React__default.createElement("div", {
|
|
260
292
|
className: "audioPlayer",
|
|
261
293
|
style: customStyles && customStyles.audioPlayer
|
|
@@ -269,8 +301,8 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
269
301
|
className: "player-layout"
|
|
270
302
|
}, volumeCtrl && /*#__PURE__*/React__default.createElement("div", {
|
|
271
303
|
className: "player-controls-secondary-outer"
|
|
272
|
-
}, /*#__PURE__*/React__default.createElement("div",
|
|
273
|
-
className: "player-volume-
|
|
304
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
305
|
+
className: "player-volume-control"
|
|
274
306
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
275
307
|
className: "player-volume-icon"
|
|
276
308
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
@@ -283,31 +315,33 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
283
315
|
}) : /*#__PURE__*/React__default.createElement("img", {
|
|
284
316
|
src: "/img/icon-volume-mute.svg",
|
|
285
317
|
alt: "Volume Mute Button"
|
|
286
|
-
}))), /*#__PURE__*/React__default.createElement("
|
|
287
|
-
className: "player-
|
|
288
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
289
|
-
className: "player-volume"
|
|
318
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
319
|
+
className: "player-timeline player-controls-secondary"
|
|
290
320
|
}, /*#__PURE__*/React__default.createElement("input", {
|
|
291
321
|
id: "player-volume",
|
|
292
322
|
type: "range",
|
|
293
|
-
className: "player-
|
|
323
|
+
className: "player-volume-progress",
|
|
294
324
|
min: 0,
|
|
295
325
|
max: 100,
|
|
296
326
|
"aria-hidden": "true",
|
|
327
|
+
"aria-valuetext": "100%",
|
|
297
328
|
onChange: function onChange(e) {
|
|
298
329
|
return volumeControl(e);
|
|
299
330
|
}
|
|
300
|
-
}))
|
|
331
|
+
})), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("img", {
|
|
332
|
+
src: "/img/icon-volume-high.svg",
|
|
333
|
+
alt: "Volume Button"
|
|
334
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
335
|
+
className: "player-volume-label"
|
|
336
|
+
}, "Volume")), /*#__PURE__*/React__default.createElement("div", {
|
|
301
337
|
className: "player-controls"
|
|
302
338
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
303
|
-
className: "player-btn-play-pause-outer"
|
|
339
|
+
className: "".concat(isPlaying ? 'is-playing' : '', " player-btn-play-pause-outer")
|
|
304
340
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
305
341
|
onClick: togglePlaying,
|
|
306
342
|
className: playBtnClass,
|
|
307
343
|
style: customStyles && customStyles.playPause
|
|
308
|
-
}, isPlaying ? /*#__PURE__*/React__default.createElement(Pause, null) : /*#__PURE__*/React__default.createElement(Play, null)))),
|
|
309
|
-
className: "player-currentTime"
|
|
310
|
-
}, calculateTime(currentTime)), /*#__PURE__*/React__default.createElement("div", {
|
|
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", {
|
|
311
345
|
className: "player-timeline"
|
|
312
346
|
}, /*#__PURE__*/React__default.createElement("input", {
|
|
313
347
|
type: "range",
|
|
@@ -316,20 +350,26 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
316
350
|
"aria-hidden": "true",
|
|
317
351
|
ref: progressBarRef,
|
|
318
352
|
onChange: changePlayerCurrentTime
|
|
319
|
-
})
|
|
353
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
354
|
+
className: "player-times"
|
|
355
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
356
|
+
className: "player-currentTime"
|
|
357
|
+
}, calculateTime(currentTime)), /*#__PURE__*/React__default.createElement("div", {
|
|
320
358
|
className: "player-duration",
|
|
321
359
|
style: customStyles && customStyles.duration
|
|
322
|
-
}, duration && !isNaN(duration) && calculateTime(duration))), /*#__PURE__*/React__default.createElement("div", {
|
|
360
|
+
}, duration && !isNaN(duration) && calculateTime(duration))))), /*#__PURE__*/React__default.createElement("div", {
|
|
323
361
|
className: "player-content"
|
|
324
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
362
|
+
}, customHtml && customHtml, /*#__PURE__*/React__default.createElement("div", {
|
|
325
363
|
className: "player-audio-type type-sm"
|
|
326
364
|
}, isLive ? /*#__PURE__*/React__default.createElement("div", {
|
|
327
365
|
className: "player-live-label"
|
|
328
366
|
}, "On Air") : /*#__PURE__*/React__default.createElement("div", {
|
|
367
|
+
className: "player-label"
|
|
368
|
+
}, "listen", /*#__PURE__*/React__default.createElement("div", {
|
|
369
|
+
className: "player-label-duration"
|
|
370
|
+
}, "[".concat(formatDuration, "]"))), /*#__PURE__*/React__default.createElement("div", {
|
|
329
371
|
className: "player-title"
|
|
330
|
-
},
|
|
331
|
-
className: "player-description"
|
|
332
|
-
}, description || '', " ")))));
|
|
372
|
+
}, title || '', " ")))));
|
|
333
373
|
};
|
|
334
374
|
|
|
335
375
|
var ReactAudioPlayer = function ReactAudioPlayer(props) {
|
|
@@ -351,7 +391,8 @@ var ReactAudioPlayer = function ReactAudioPlayer(props) {
|
|
|
351
391
|
duration = _useAudioPlayer.duration,
|
|
352
392
|
volumeControl = _useAudioPlayer.volumeControl,
|
|
353
393
|
toggleMute = _useAudioPlayer.toggleMute,
|
|
354
|
-
isMuted = _useAudioPlayer.isMuted
|
|
394
|
+
isMuted = _useAudioPlayer.isMuted,
|
|
395
|
+
formatCalculateTime = _useAudioPlayer.formatCalculateTime;
|
|
355
396
|
return /*#__PURE__*/React__default.createElement(ReactAudioPlayerInner, _extends({}, props, {
|
|
356
397
|
audioPlayerRef: audioPlayerRef,
|
|
357
398
|
progressBarRef: progressBarRef,
|
|
@@ -365,7 +406,8 @@ var ReactAudioPlayer = function ReactAudioPlayer(props) {
|
|
|
365
406
|
duration: duration,
|
|
366
407
|
volumeControl: volumeControl,
|
|
367
408
|
toggleMute: toggleMute,
|
|
368
|
-
isMuted: isMuted
|
|
409
|
+
isMuted: isMuted,
|
|
410
|
+
formatCalculateTime: formatCalculateTime
|
|
369
411
|
}));
|
|
370
412
|
};
|
|
371
413
|
|