Skip to content

Commit cbc35c9

Browse files
authored
Merge pull request #14 from riyaddecoder/master
feat: update package version.
2 parents 4abfd5e + ddfef50 commit cbc35c9

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

documentation/docs/public/clarity.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
};
77
t = l.createElement(r);
88
t.async = 1;
9-
t.src = "https://www.clarity.ms/tag/" + i;
9+
t.src = 'https://www.clarity.ms/tag/' + i;
1010
y = l.getElementsByTagName(r)[0];
1111
y.parentNode.insertBefore(t, y);
12-
})(window, document, "clarity", "script", "itd5tbp46u");
12+
})(window, document, 'clarity', 'script', 'itd5tbp46u');

documentation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"react": "^18.3.1",
14-
"react-audio-play": "^1.0.2",
14+
"react-audio-play": "^1.0.3",
1515
"react-dom": "^18.3.1"
1616
}
1717
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-audio-play",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "React audio player component",
55
"homepage": "https://riyaddecoder.github.io/react-audio-play/",
66
"main": "dist/cjs/index.js",

src/components/AudioPlayer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ export const AudioPlayer: React.FC<AudioInterface> = ({
6464
// eslint-disable-next-line react-hooks/exhaustive-deps
6565
}, [src]);
6666

67+
useEffect(() => {
68+
if (audioRef.current?.duration && audioRef.current.duration !== Infinity) {
69+
setTotalTime(formatTime(audioRef.current.duration));
70+
}
71+
}, [audioRef.current?.duration]);
72+
6773
useEffect(() => {
6874
if (!isNaN(volume)) {
6975
const tempVol = volume > 100 ? 100 : volume < 0 ? 0 : volume;
@@ -87,6 +93,8 @@ export const AudioPlayer: React.FC<AudioInterface> = ({
8793

8894
const handleReload = () => {
8995
if (audioRef.current) {
96+
setIsPlaying(false);
97+
setTotalTime('--:--');
9098
setCanPlay(false);
9199
setHasError(false);
92100
audioRef.current.src = src;

tests/common.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import 'jest-canvas-mock';
55

66
import { AudioPlayer } from '../src';
77

8+
beforeAll(() => {
9+
Object.defineProperty(HTMLMediaElement.prototype, 'load', {
10+
configurable: true,
11+
value: jest.fn() // Mock implementation of the load method
12+
});
13+
});
14+
815
describe('Common render', () => {
916
it('renders without crashing', () => {
1017
render(<AudioPlayer src="" />);

0 commit comments

Comments
 (0)