@popmenu/audio-player 0.27.0
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 +9 -0
- package/build/components/AudioPlayer/AudioPlayer.d.ts +3 -0
- package/build/components/AudioPlayer/AudioPlayerProps.d.ts +10 -0
- package/build/components/AudioPlayer/index.d.ts +2 -0
- package/build/components/AudioPlayer/util/audioPlayerReducer.d.ts +11 -0
- package/build/components/AudioPlayer/util/formatTime.d.ts +1 -0
- package/build/components/AudioPlayer/util/index.d.ts +5 -0
- package/build/components/AudioPlayer/util/setupAudioRef.d.ts +8 -0
- package/build/components/AudioPlayer/util/types.d.ts +77 -0
- package/build/components/AudioPlayer/util/useVolumeIcon.d.ts +2 -0
- package/build/components/index.d.ts +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.es.js +1043 -0
- package/build/index.es.js.map +1 -0
- package/build/index.js +1082 -0
- package/build/index.js.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type AudioPlayerClasses = 'root' | 'playbackToggle' | 'volumeToggle' | 'volumeSlider' | 'playbackSlider' | 'playbackText' | 'lengthText';
|
|
2
|
+
export interface AudioPlayerProps {
|
|
3
|
+
/** The URL of the audio to embed. */
|
|
4
|
+
src?: string;
|
|
5
|
+
/** style classes */
|
|
6
|
+
classes?: {
|
|
7
|
+
[Key in AudioPlayerClasses]?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PLAYBACK_STATES, CONTROL_LABELS, AudioPlayerState, AudioPlayerEvent, VOLUME_CONTROL_STATES } from './types';
|
|
2
|
+
export declare const initialAudioPlayerState: {
|
|
3
|
+
playback: PLAYBACK_STATES;
|
|
4
|
+
volumeControls: VOLUME_CONTROL_STATES;
|
|
5
|
+
context: {
|
|
6
|
+
volume: number;
|
|
7
|
+
playbackButtonLabel: CONTROL_LABELS;
|
|
8
|
+
volumeButtonLabel: CONTROL_LABELS;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const audioPlayerReducer: (state: AudioPlayerState, event: AudioPlayerEvent) => AudioPlayerState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatTime: (time: number, remaning?: boolean) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { AudioPlayerEvent } from './types';
|
|
3
|
+
interface Config {
|
|
4
|
+
audioRef: RefObject<HTMLAudioElement>;
|
|
5
|
+
send: (event: AudioPlayerEvent) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const setupAudioRef: (config: Config) => () => (() => void);
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export declare enum AUDIO_PLAYER_EVENT_TYPES {
|
|
3
|
+
TOGGLE_PLAYBACK = "TOGGLE_PLAYBACK",
|
|
4
|
+
TOGGLE_VOLUME_CONTROL = "TOGGLE_VOLUME_CONTROL",
|
|
5
|
+
TOGGLE_MUTE = "TOGGLE_MUTE",
|
|
6
|
+
VOLUME_CHANGE = "VOLUME_CHANGE",
|
|
7
|
+
TIME_CHANGE = "TIME_CHANGE",
|
|
8
|
+
DURATION_CHANGE = "DURATION_CHANGE",
|
|
9
|
+
SET_TIME = "SET_TIME",
|
|
10
|
+
CAN_PLAY = "CAN_PLAY",
|
|
11
|
+
RESET = "RESET"
|
|
12
|
+
}
|
|
13
|
+
interface SetVolumeEvent {
|
|
14
|
+
type: AUDIO_PLAYER_EVENT_TYPES.VOLUME_CHANGE;
|
|
15
|
+
context: Pick<AudioPlayerExtendState, 'volume'>;
|
|
16
|
+
}
|
|
17
|
+
interface TogglePlaybackEvent {
|
|
18
|
+
type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_PLAYBACK;
|
|
19
|
+
}
|
|
20
|
+
interface ToggleVolumeControlEvent {
|
|
21
|
+
type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_VOLUME_CONTROL;
|
|
22
|
+
}
|
|
23
|
+
interface TimeChangeEvent {
|
|
24
|
+
type: AUDIO_PLAYER_EVENT_TYPES.TIME_CHANGE;
|
|
25
|
+
context: {
|
|
26
|
+
currentTime: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface DurationChangeEvent {
|
|
30
|
+
type: AUDIO_PLAYER_EVENT_TYPES.DURATION_CHANGE;
|
|
31
|
+
context: {
|
|
32
|
+
duration: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
interface ToggleMuteEvent {
|
|
36
|
+
type: AUDIO_PLAYER_EVENT_TYPES.TOGGLE_MUTE;
|
|
37
|
+
}
|
|
38
|
+
interface SetTimeEvent {
|
|
39
|
+
type: AUDIO_PLAYER_EVENT_TYPES.SET_TIME;
|
|
40
|
+
context: {
|
|
41
|
+
time: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface CanPlayEvent {
|
|
45
|
+
type: AUDIO_PLAYER_EVENT_TYPES.CAN_PLAY;
|
|
46
|
+
}
|
|
47
|
+
interface ResetEvent {
|
|
48
|
+
type: AUDIO_PLAYER_EVENT_TYPES.RESET;
|
|
49
|
+
}
|
|
50
|
+
export declare type AudioPlayerEvent = TogglePlaybackEvent | ToggleVolumeControlEvent | SetVolumeEvent | TimeChangeEvent | DurationChangeEvent | ToggleMuteEvent | SetTimeEvent | CanPlayEvent | ResetEvent;
|
|
51
|
+
export declare enum PLAYBACK_STATES {
|
|
52
|
+
NONE = "NONE",
|
|
53
|
+
PAUSED = "PAUSED",
|
|
54
|
+
PLAYING = "PLAYING"
|
|
55
|
+
}
|
|
56
|
+
export declare enum CONTROL_LABELS {
|
|
57
|
+
PAUSE = "PAUSE",
|
|
58
|
+
PLAY = "PLAY",
|
|
59
|
+
MUTE = "MUTE",
|
|
60
|
+
UNMUTE = "UNMUTE"
|
|
61
|
+
}
|
|
62
|
+
export declare enum VOLUME_CONTROL_STATES {
|
|
63
|
+
SHOW = "SHOW",
|
|
64
|
+
HIDE = "HIDE"
|
|
65
|
+
}
|
|
66
|
+
export interface AudioPlayerExtendState {
|
|
67
|
+
volume: number;
|
|
68
|
+
audioRef: RefObject<HTMLAudioElement>;
|
|
69
|
+
playbackButtonLabel: CONTROL_LABELS;
|
|
70
|
+
volumeButtonLabel: CONTROL_LABELS;
|
|
71
|
+
}
|
|
72
|
+
export interface AudioPlayerState {
|
|
73
|
+
playback: PLAYBACK_STATES;
|
|
74
|
+
volumeControls: VOLUME_CONTROL_STATES;
|
|
75
|
+
context: AudioPlayerExtendState;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AudioPlayer, AudioPlayerProps } from './AudioPlayer';
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|