apm-react-audio-player 1.0.10 → 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 +53 -23
- 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
|
|
|
@@ -252,7 +270,6 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
252
270
|
|
|
253
271
|
var customStyles = props ? props.style : '';
|
|
254
272
|
var title = props.title,
|
|
255
|
-
description = props.description,
|
|
256
273
|
audioSrc = props.audioSrc,
|
|
257
274
|
volumeCtrl = props.volumeCtrl,
|
|
258
275
|
playBtnClass = props.playBtnClass,
|
|
@@ -267,7 +284,10 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
267
284
|
duration = props.duration,
|
|
268
285
|
volumeControl = props.volumeControl,
|
|
269
286
|
toggleMute = props.toggleMute,
|
|
270
|
-
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);
|
|
271
291
|
return audioSrc && /*#__PURE__*/React__default.createElement("div", {
|
|
272
292
|
className: "audioPlayer",
|
|
273
293
|
style: customStyles && customStyles.audioPlayer
|
|
@@ -281,8 +301,8 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
281
301
|
className: "player-layout"
|
|
282
302
|
}, volumeCtrl && /*#__PURE__*/React__default.createElement("div", {
|
|
283
303
|
className: "player-controls-secondary-outer"
|
|
284
|
-
}, /*#__PURE__*/React__default.createElement("div",
|
|
285
|
-
className: "player-volume-
|
|
304
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
305
|
+
className: "player-volume-control"
|
|
286
306
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
287
307
|
className: "player-volume-icon"
|
|
288
308
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
@@ -295,31 +315,33 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
295
315
|
}) : /*#__PURE__*/React__default.createElement("img", {
|
|
296
316
|
src: "/img/icon-volume-mute.svg",
|
|
297
317
|
alt: "Volume Mute Button"
|
|
298
|
-
}))), /*#__PURE__*/React__default.createElement("
|
|
299
|
-
className: "player-
|
|
300
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
301
|
-
className: "player-volume"
|
|
318
|
+
}))), /*#__PURE__*/React__default.createElement("div", {
|
|
319
|
+
className: "player-timeline player-controls-secondary"
|
|
302
320
|
}, /*#__PURE__*/React__default.createElement("input", {
|
|
303
321
|
id: "player-volume",
|
|
304
322
|
type: "range",
|
|
305
|
-
className: "player-
|
|
323
|
+
className: "player-volume-progress",
|
|
306
324
|
min: 0,
|
|
307
325
|
max: 100,
|
|
308
326
|
"aria-hidden": "true",
|
|
327
|
+
"aria-valuetext": "100%",
|
|
309
328
|
onChange: function onChange(e) {
|
|
310
329
|
return volumeControl(e);
|
|
311
330
|
}
|
|
312
|
-
}))
|
|
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", {
|
|
313
337
|
className: "player-controls"
|
|
314
338
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
315
|
-
className: "player-btn-play-pause-outer"
|
|
339
|
+
className: "".concat(isPlaying ? 'is-playing' : '', " player-btn-play-pause-outer")
|
|
316
340
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
317
341
|
onClick: togglePlaying,
|
|
318
342
|
className: playBtnClass,
|
|
319
343
|
style: customStyles && customStyles.playPause
|
|
320
|
-
}, isPlaying ? /*#__PURE__*/React__default.createElement(Pause, null) : /*#__PURE__*/React__default.createElement(Play, null)))),
|
|
321
|
-
className: "player-currentTime"
|
|
322
|
-
}, 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", {
|
|
323
345
|
className: "player-timeline"
|
|
324
346
|
}, /*#__PURE__*/React__default.createElement("input", {
|
|
325
347
|
type: "range",
|
|
@@ -328,20 +350,26 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
328
350
|
"aria-hidden": "true",
|
|
329
351
|
ref: progressBarRef,
|
|
330
352
|
onChange: changePlayerCurrentTime
|
|
331
|
-
})
|
|
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", {
|
|
332
358
|
className: "player-duration",
|
|
333
359
|
style: customStyles && customStyles.duration
|
|
334
|
-
}, duration && !isNaN(duration) && calculateTime(duration))), /*#__PURE__*/React__default.createElement("div", {
|
|
360
|
+
}, duration && !isNaN(duration) && calculateTime(duration))))), /*#__PURE__*/React__default.createElement("div", {
|
|
335
361
|
className: "player-content"
|
|
336
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
362
|
+
}, customHtml && customHtml, /*#__PURE__*/React__default.createElement("div", {
|
|
337
363
|
className: "player-audio-type type-sm"
|
|
338
364
|
}, isLive ? /*#__PURE__*/React__default.createElement("div", {
|
|
339
365
|
className: "player-live-label"
|
|
340
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", {
|
|
341
371
|
className: "player-title"
|
|
342
|
-
},
|
|
343
|
-
className: "player-description"
|
|
344
|
-
}, description || '', " ")))));
|
|
372
|
+
}, title || '', " ")))));
|
|
345
373
|
};
|
|
346
374
|
|
|
347
375
|
var ReactAudioPlayer = function ReactAudioPlayer(props) {
|
|
@@ -363,7 +391,8 @@ var ReactAudioPlayer = function ReactAudioPlayer(props) {
|
|
|
363
391
|
duration = _useAudioPlayer.duration,
|
|
364
392
|
volumeControl = _useAudioPlayer.volumeControl,
|
|
365
393
|
toggleMute = _useAudioPlayer.toggleMute,
|
|
366
|
-
isMuted = _useAudioPlayer.isMuted
|
|
394
|
+
isMuted = _useAudioPlayer.isMuted,
|
|
395
|
+
formatCalculateTime = _useAudioPlayer.formatCalculateTime;
|
|
367
396
|
return /*#__PURE__*/React__default.createElement(ReactAudioPlayerInner, _extends({}, props, {
|
|
368
397
|
audioPlayerRef: audioPlayerRef,
|
|
369
398
|
progressBarRef: progressBarRef,
|
|
@@ -377,7 +406,8 @@ var ReactAudioPlayer = function ReactAudioPlayer(props) {
|
|
|
377
406
|
duration: duration,
|
|
378
407
|
volumeControl: volumeControl,
|
|
379
408
|
toggleMute: toggleMute,
|
|
380
|
-
isMuted: isMuted
|
|
409
|
+
isMuted: isMuted,
|
|
410
|
+
formatCalculateTime: formatCalculateTime
|
|
381
411
|
}));
|
|
382
412
|
};
|
|
383
413
|
|