apm-react-audio-player 1.0.19 → 1.0.21
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/README.md +81 -30
- package/dist/index.js +1 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ This is a light react audio player that is wrapped around a HTML5 audio tag, cre
|
|
|
4
4
|
|
|
5
5
|
The library was designed to add a audio player to a body of a story which will not trigger the static audio player.
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
10
10
|
|
|
@@ -56,52 +56,103 @@ The library uses named exports for all modules.
|
|
|
56
56
|
To import the player module:
|
|
57
57
|
|
|
58
58
|
```javascript
|
|
59
|
-
import {
|
|
59
|
+
import { ReactAudioPlayerInner, useAudioPlayer } from 'apm-react-audio-player';
|
|
60
60
|
```
|
|
61
61
|
## Usage
|
|
62
62
|
|
|
63
63
|
### Props
|
|
64
64
|
See the [audio tag documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) for detailed explanations of these attributes.
|
|
65
65
|
|
|
66
|
+
|
|
66
67
|
Prop | Type | Default | Notes
|
|
67
68
|
--- | --- | --- | ---
|
|
68
|
-
`title` | String | *empty string* |
|
|
69
|
-
`
|
|
70
|
-
`
|
|
71
|
-
`
|
|
72
|
-
`
|
|
69
|
+
`title` | String | *empty string* | The title of the audio track
|
|
70
|
+
`audioSrc` | String | *empty string* | The source URL of the audio file
|
|
71
|
+
`description` | String | *empty string* | The description of the audio track
|
|
72
|
+
`audioPlayerRef` | Object | *empty object* | A ref object for the audio player
|
|
73
|
+
`progressBarRef` | Object | *empty object* | A ref object for the progress bar
|
|
74
|
+
`onLoadedMetadata` | Function | --- | A function to handle the `loadedmetadata` event
|
|
75
|
+
`togglePlaying` | Function | --- | A function to toggle the playing state
|
|
76
|
+
`isPlaying` | Boolean | false | Whether the audio is currently playing
|
|
77
|
+
`isMuted` | Boolean | false | Whether the audio is currently muted
|
|
78
|
+
`toggleMute` | Function | --- | A function to toggle the mute state
|
|
79
|
+
`volumeControl` | Function | --- | A function to control the volume
|
|
80
|
+
`currentTime` | Number | null | The current time of the audio track
|
|
81
|
+
`duration` | Number | null | The duration of the audio track
|
|
82
|
+
`rewindControl` | Function | --- | A function to rewind the audio track
|
|
83
|
+
`forwardControl` | Function | --- | A function to fast forward the audio track
|
|
84
|
+
`changePlayerCurrentTime` | Function | --- | A function to change the current time of the audio track
|
|
85
|
+
`calculateTime` | Function | --- | A function to calculate the time for the audio track
|
|
86
|
+
`formatCalculateTime` | Function | --- | A function to format the calculated time
|
|
87
|
+
`playBtnClass` | String | *empty string* | The CSS class for the play button
|
|
88
|
+
`customStyles` | Object | --- | Custom styles for the audio player
|
|
89
|
+
`customHtml` | JSX.Element | `<></>` | Custom HTML to be rendered inside the player
|
|
73
90
|
|
|
74
91
|
### Example
|
|
75
92
|
|
|
76
93
|
```javascript
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
import { ReactAudioPlayerInner, useAudioPlayer } from 'apm-react-audio-player';
|
|
95
|
+
|
|
96
|
+
const Example = () => {
|
|
97
|
+
|
|
98
|
+
const audioPlayerRef = React.useRef();
|
|
99
|
+
const progressBarRef = React.useRef();
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
onLoadedMetadata,
|
|
103
|
+
calculateTime,
|
|
104
|
+
volumeControl,
|
|
105
|
+
togglePlaying,
|
|
106
|
+
toggleMute,
|
|
107
|
+
isMuted,
|
|
108
|
+
changePlayerCurrentTime,
|
|
109
|
+
play,
|
|
110
|
+
isPlaying,
|
|
111
|
+
isFinishedPlaying,
|
|
112
|
+
currentTime,
|
|
113
|
+
duration,
|
|
114
|
+
formatCalculateTime,
|
|
115
|
+
rewindControl,
|
|
116
|
+
forwardControl
|
|
117
|
+
} = useAudioPlayer(audioPlayerRef, progressBarRef);
|
|
118
|
+
|
|
92
119
|
return (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
120
|
+
<ReactAudioPlayerInner
|
|
121
|
+
title={'MPR NEWS'}
|
|
122
|
+
audioSrc={'https://play.publicradio.org/web/o/minnesota/podcasts/art_hounds/2024/06/26/arthounds_art-hounds-franconia_20240626_64.mp3'}
|
|
123
|
+
description={'description'}
|
|
124
|
+
playBtnClass="player-btn player-btn-playpause js-player-play"
|
|
125
|
+
audioPlayerRef={audioPlayerRef}
|
|
126
|
+
progressBarRef={progressBarRef}
|
|
127
|
+
onLoadedMetadata={onLoadedMetadata}
|
|
128
|
+
play={play}
|
|
129
|
+
isPlaying={isPlaying}
|
|
130
|
+
togglePlaying={togglePlaying}
|
|
131
|
+
isMuted={isMuted}
|
|
132
|
+
currentTime={currentTime}
|
|
133
|
+
duration={duration}
|
|
134
|
+
isAudioFinished={isFinishedPlaying}
|
|
135
|
+
toggleMute={toggleMute}
|
|
136
|
+
volumeCtrl={volumeControl}
|
|
137
|
+
changePlayerCurrentTime={changePlayerCurrentTime}
|
|
138
|
+
rewindControl={rewindControl}
|
|
139
|
+
forwardControl={forwardControl}
|
|
140
|
+
calculateTime={calculateTime}
|
|
141
|
+
formatCalculateTime={formatCalculateTime}
|
|
142
|
+
customHtml={<></>}
|
|
99
143
|
/>
|
|
100
|
-
|
|
101
|
-
}
|
|
144
|
+
)
|
|
102
145
|
}
|
|
103
146
|
```
|
|
104
147
|
|
|
148
|
+
## Publishing
|
|
149
|
+
|
|
150
|
+
1. Ensure every merge request and/or change to `apm-react-audio-player` should always come with an updated version (ex. 1.0.17 to 1.0.18) in the package.json.
|
|
151
|
+
2. Once the changes is on Main branch, locally run:
|
|
152
|
+
1. `git pull main`
|
|
153
|
+
2. `yarn run build` or `npm run build`
|
|
154
|
+
3. `yarn publish` or `npm publish`
|
|
155
|
+
|
|
105
156
|
## License
|
|
106
157
|
|
|
107
158
|
MIT © [Phanx091](https://github.com/Phanx091)
|
package/dist/index.js
CHANGED
|
@@ -356,8 +356,7 @@ var ReactAudioPlayerInner = function ReactAudioPlayerInner(props) {
|
|
|
356
356
|
}, /*#__PURE__*/React__default.createElement("button", {
|
|
357
357
|
onClick: togglePlaying,
|
|
358
358
|
className: playBtnClass,
|
|
359
|
-
style: customStyles && customStyles.playPause
|
|
360
|
-
id: "playbutton"
|
|
359
|
+
style: customStyles && customStyles.playPause
|
|
361
360
|
}, isPlaying ? /*#__PURE__*/React__default.createElement(Pause, null) : /*#__PURE__*/React__default.createElement(Play, null))), !isLive && /*#__PURE__*/React__default.createElement("div", {
|
|
362
361
|
className: "player-backward-forward-controls"
|
|
363
362
|
}, /*#__PURE__*/React__default.createElement("button", {
|