react-modern-audio-player 2.1.0 → 2.3.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 +196 -43
- package/dist/index.css +1 -1
- package/dist/index.es.js +1500 -1217
- package/dist/types/api/useAudioPlayer.d.ts +2 -0
- package/dist/types/api/useAudioPlayerPlayback.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/PlaybackContext.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/StateContext/audio.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/StateContext/element.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/StateContext/index.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Context/StateContext/placement.d.ts +7 -5
- package/dist/types/components/AudioPlayer/Context/UIContext.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Context/dispatchContext.d.ts +5 -2
- package/dist/types/{hooks/context → components/AudioPlayer/Context/hooks}/index.d.ts +0 -1
- package/dist/types/components/AudioPlayer/Context/hooks/useAudioAttrsContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/usePlaybackContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useResourceContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useTimeContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useTrackContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Context/hooks/useUIContext.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/index.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Context/providerProps.d.ts +2 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/RepeatTypeBtn.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/TransportControls/index.d.ts +4 -0
- package/dist/types/components/AudioPlayer/Interface/Controller/Button/index.d.ts +4 -3
- package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/index.d.ts +5 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/Input/Progress/index.d.ts +12 -1
- package/dist/types/components/AudioPlayer/Interface/Controller/SpeedSelector/SpeedSelector.d.ts +10 -0
- package/dist/types/components/AudioPlayer/Interface/Controller/SpeedSelector/index.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/index.d.ts +7 -1
- package/dist/types/components/AudioPlayer/Interface/Information/Artwork.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Information/TrackInfo.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/Information/TrackTime/index.d.ts +3 -1
- package/dist/types/components/AudioPlayer/Interface/PlayListEmpty/index.d.ts +6 -0
- package/dist/types/components/AudioPlayer/Interface/compound/index.d.ts +3 -0
- package/dist/types/components/AudioPlayer/Interface/compound/slotMetaMap.d.ts +10 -0
- package/dist/types/components/AudioPlayer/Interface/compound/useCompoundSlots.d.ts +6 -0
- package/dist/types/components/AudioPlayer/Interface/compound/useDuplicateSlotWarning.d.ts +7 -0
- package/dist/types/components/AudioPlayer/Interface/contexts/index.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/contexts/playListEmptyContext.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Interface/contexts/playListPortalContext.d.ts +1 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/index.d.ts +4 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/useDropdownAutoPlacement.d.ts +5 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/useGridTemplate.d.ts +3 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/useResolvedDropdownProps.d.ts +18 -0
- package/dist/types/components/AudioPlayer/Interface/hooks/useResolvedGridArea.d.ts +2 -0
- package/dist/types/components/AudioPlayer/Player/index.d.ts +2 -2
- package/dist/types/components/AudioPlayer/Provider/AudioPlayerStateProvider.d.ts +2 -2
- package/dist/types/components/AudioPlayer/index.d.ts +28 -5
- package/dist/types/components/Drawer/Drawer.d.ts +1 -0
- package/dist/types/components/Grid/Item.d.ts +3 -2
- package/dist/types/components/Grid/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/ssr.d.ts +0 -2
- package/llms.txt +61 -0
- package/package.json +4 -2
- package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/useVolume.d.ts +0 -5
- package/dist/types/hooks/context/useAudioAttrsContext.d.ts +0 -2
- package/dist/types/hooks/context/usePlaybackContext.d.ts +0 -2
- package/dist/types/hooks/context/useResourceContext.d.ts +0 -2
- package/dist/types/hooks/context/useTimeContext.d.ts +0 -2
- package/dist/types/hooks/context/useTrackContext.d.ts +0 -2
- package/dist/types/hooks/context/useUIContext.d.ts +0 -1
- package/dist/types/hooks/useGridTemplate.d.ts +0 -2
- /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{NextBtn.d.ts → TransportControls/NextBtn.d.ts} +0 -0
- /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{PlayBtn.d.ts → TransportControls/PlayBtn.d.ts} +0 -0
- /package/dist/types/components/AudioPlayer/Interface/Controller/Button/{PrevBtn.d.ts → TransportControls/PrevBtn.d.ts} +0 -0
- /package/dist/types/{utils → components/AudioPlayer/utils}/clampVolume.d.ts +0 -0
- /package/dist/types/hooks/{context/useNonNullableContext.d.ts → useNonNullableContext.d.ts} +0 -0
|
@@ -6,6 +6,7 @@ export interface AudioPlayerControls {
|
|
|
6
6
|
duration: number;
|
|
7
7
|
repeatType: RepeatType;
|
|
8
8
|
muted: boolean;
|
|
9
|
+
playbackRate: number;
|
|
9
10
|
currentTrack: AudioData | null;
|
|
10
11
|
currentIndex: number;
|
|
11
12
|
playList: ReadonlyArray<AudioData>;
|
|
@@ -18,6 +19,7 @@ export interface AudioPlayerControls {
|
|
|
18
19
|
setVolume: (volume: number) => void;
|
|
19
20
|
toggleMute: () => void;
|
|
20
21
|
setTrack: (index: number) => void;
|
|
22
|
+
setPlaybackRate: (rate: number) => void;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Convenience facade that composes all domain sub-hooks into a single flat
|
|
@@ -2,8 +2,10 @@ import { RepeatType } from '../components/AudioPlayer/Context/StateContext';
|
|
|
2
2
|
export interface AudioPlayerPlaybackControls {
|
|
3
3
|
isPlaying: boolean;
|
|
4
4
|
repeatType: RepeatType;
|
|
5
|
+
playbackRate: number;
|
|
5
6
|
play: () => void;
|
|
6
7
|
pause: () => void;
|
|
7
8
|
togglePlay: () => void;
|
|
9
|
+
setPlaybackRate: (rate: number) => void;
|
|
8
10
|
}
|
|
9
11
|
export declare const useAudioPlayerPlayback: () => AudioPlayerPlaybackControls;
|
|
@@ -8,6 +8,7 @@ export type AudioCustomProps = {
|
|
|
8
8
|
volume?: number;
|
|
9
9
|
currentTime?: number;
|
|
10
10
|
duration?: number;
|
|
11
|
+
playbackRate?: number;
|
|
11
12
|
};
|
|
12
13
|
export declare const DEFAULT_AUDIO_STATE: {
|
|
13
14
|
readonly isPlaying: false;
|
|
@@ -16,6 +17,7 @@ export declare const DEFAULT_AUDIO_STATE: {
|
|
|
16
17
|
readonly repeatType: RepeatType;
|
|
17
18
|
readonly currentTime: 0;
|
|
18
19
|
readonly duration: 0;
|
|
20
|
+
readonly playbackRate: 1;
|
|
19
21
|
};
|
|
20
22
|
export type AudioData = {
|
|
21
23
|
src: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AudioState } from './audio';
|
|
2
2
|
import { ActiveUI, CoverImgsCss, ElementRefs, CustomIcons, PlayList } from './element';
|
|
3
|
-
import { PlayListPlacement, InterfacePlacement, PlayerPlacement, VolumeSliderPlacement } from './placement';
|
|
3
|
+
import { PlayListPlacement, InterfacePlacement, PlayerPlacement, SpeedSelectorPlacement, VolumeSliderPlacement } from './placement';
|
|
4
4
|
export interface AudioPlayerStateContext {
|
|
5
5
|
playList: PlayList;
|
|
6
6
|
curPlayId: number;
|
|
@@ -11,6 +11,7 @@ export interface AudioPlayerStateContext {
|
|
|
11
11
|
playerPlacement?: PlayerPlacement;
|
|
12
12
|
interfacePlacement?: InterfacePlacement;
|
|
13
13
|
volumeSliderPlacement?: VolumeSliderPlacement;
|
|
14
|
+
speedSelectorPlacement?: SpeedSelectorPlacement;
|
|
14
15
|
elementRefs?: ElementRefs;
|
|
15
16
|
customIcons?: CustomIcons;
|
|
16
17
|
coverImgsCss?: CoverImgsCss;
|
|
@@ -19,6 +20,7 @@ export interface AudioPlayerStateContext {
|
|
|
19
20
|
}
|
|
20
21
|
export type InitialStates = Partial<AudioState> & {
|
|
21
22
|
curPlayId: number;
|
|
23
|
+
playListExpanded?: boolean;
|
|
22
24
|
};
|
|
23
25
|
export * from './audio';
|
|
24
26
|
export * from './element';
|
|
@@ -2,24 +2,26 @@ import { DropdownContentPlacement } from '../../../Dropdown';
|
|
|
2
2
|
import { NumbersToUnionNum } from '../../../../utils/generateUnionNumType';
|
|
3
3
|
import { ActiveUI } from './element';
|
|
4
4
|
export type VolumeSliderPlacement = DropdownContentPlacement;
|
|
5
|
+
export type SpeedSelectorPlacement = DropdownContentPlacement;
|
|
5
6
|
export type PlayListPlacement = "bottom" | "top";
|
|
6
7
|
export type PlayerPlacement = "bottom" | "top" | "bottom-left" | "bottom-right" | "top-left" | "top-right" | "static";
|
|
7
|
-
export declare const
|
|
8
|
+
export declare const DEFAULT_INTERFACE_GRID_BOUND = 11;
|
|
8
9
|
export type InterfacePlacementKey = Exclude<keyof ActiveUI, "all" | "prevNnext" | "trackTime" | "volumeSlider"> | "trackTimeCurrent" | "trackTimeDuration";
|
|
9
|
-
export type InterfaceGridTemplateArea<TMaxLength extends number = typeof
|
|
10
|
+
export type InterfaceGridTemplateArea<TMaxLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND> = Partial<Record<InterfacePlacementKey, `row${NumbersToUnionNum<TMaxLength>}-${NumbersToUnionNum<TMaxLength>}`>>;
|
|
10
11
|
export type InterfaceGridCustomComponentsArea<TMaxLength extends number> = Partial<Record<string, `row${NumbersToUnionNum<TMaxLength>}-${NumbersToUnionNum<TMaxLength>}`>>;
|
|
11
12
|
export type InterfaceGridItemArea = Partial<Record<InterfacePlacementKey, string>>;
|
|
12
|
-
export type InterfacePlacement<TMaxLength extends number = typeof
|
|
13
|
+
export type InterfacePlacement<TMaxLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND> = {
|
|
13
14
|
templateArea?: InterfaceGridTemplateArea<TMaxLength>;
|
|
14
15
|
customComponentsArea?: InterfaceGridCustomComponentsArea<TMaxLength>;
|
|
15
16
|
itemCustomArea?: InterfaceGridItemArea;
|
|
16
17
|
};
|
|
17
18
|
export declare const defaultInterfacePlacement: {
|
|
18
|
-
templateArea: Required<InterfaceGridTemplateArea<typeof
|
|
19
|
+
templateArea: Required<InterfaceGridTemplateArea<typeof DEFAULT_INTERFACE_GRID_BOUND>>;
|
|
19
20
|
};
|
|
20
|
-
export interface Placements<TInterfacePlacementLength extends number = typeof
|
|
21
|
+
export interface Placements<TInterfacePlacementLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND> {
|
|
21
22
|
playListPlacement: PlayListPlacement;
|
|
22
23
|
interfacePlacement: InterfacePlacement<TInterfacePlacementLength>;
|
|
23
24
|
volumeSliderPlacement: VolumeSliderPlacement | undefined;
|
|
25
|
+
speedSelectorPlacement: SpeedSelectorPlacement | undefined;
|
|
24
26
|
playerPlacement: PlayerPlacement | undefined;
|
|
25
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActiveUI, InterfacePlacement, PlayListPlacement, PlayerPlacement, VolumeSliderPlacement } from './StateContext';
|
|
1
|
+
import { ActiveUI, InterfacePlacement, PlayListPlacement, PlayerPlacement, SpeedSelectorPlacement, VolumeSliderPlacement } from './StateContext';
|
|
2
2
|
export type ColorScheme = "light" | "dark";
|
|
3
3
|
export interface UIContext {
|
|
4
4
|
activeUI: ActiveUI;
|
|
@@ -6,6 +6,8 @@ export interface UIContext {
|
|
|
6
6
|
playerPlacement?: PlayerPlacement;
|
|
7
7
|
interfacePlacement?: InterfacePlacement;
|
|
8
8
|
volumeSliderPlacement?: VolumeSliderPlacement;
|
|
9
|
+
speedSelectorPlacement?: SpeedSelectorPlacement;
|
|
9
10
|
colorScheme?: ColorScheme;
|
|
11
|
+
playListExpanded?: boolean;
|
|
10
12
|
}
|
|
11
13
|
export declare const uiContext: import('react').Context<UIContext | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
|
-
import { RepeatType, PlayList, PlayListPlacement, PlayerPlacement, ActiveUI, ElementRefs, CustomIcons, InterfacePlacement, CoverImgsCss, VolumeSliderPlacement,
|
|
3
|
-
export type AudioContextAction<TInterfacePlacementLength extends number = typeof
|
|
2
|
+
import { RepeatType, PlayList, PlayListPlacement, PlayerPlacement, ActiveUI, ElementRefs, CustomIcons, InterfacePlacement, CoverImgsCss, VolumeSliderPlacement, DEFAULT_INTERFACE_GRID_BOUND, AudioState } from './StateContext';
|
|
3
|
+
export type AudioContextAction<TInterfacePlacementLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND> = {
|
|
4
4
|
type: "NEXT_AUDIO";
|
|
5
5
|
} | {
|
|
6
6
|
type: "PREV_AUDIO";
|
|
@@ -34,6 +34,9 @@ export type AudioContextAction<TInterfacePlacementLength extends number = typeof
|
|
|
34
34
|
} | {
|
|
35
35
|
type: "SET_MUTED";
|
|
36
36
|
muted: boolean;
|
|
37
|
+
} | {
|
|
38
|
+
type: "SET_PLAYBACK_RATE";
|
|
39
|
+
playbackRate: number;
|
|
37
40
|
} | {
|
|
38
41
|
type: "SET_ACTIVE_UI";
|
|
39
42
|
activeUI: ActiveUI;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useUIContext: () => import('../UIContext').UIContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActiveUI, CoverImgsCss, CustomIcons, InitialStates, InterfacePlacement, PlayList, PlayListPlacement, PlayerPlacement, VolumeSliderPlacement } from './StateContext';
|
|
1
|
+
import { ActiveUI, CoverImgsCss, CustomIcons, InitialStates, InterfacePlacement, PlayList, PlayListPlacement, PlayerPlacement, SpeedSelectorPlacement, VolumeSliderPlacement } from './StateContext';
|
|
2
2
|
export interface AudioPlayerStateProviderProps<TInterfacePlacementLength extends number> {
|
|
3
3
|
playList: PlayList;
|
|
4
4
|
audioInitialState?: InitialStates;
|
|
@@ -10,5 +10,6 @@ export interface AudioPlayerStateProviderProps<TInterfacePlacementLength extends
|
|
|
10
10
|
playList?: PlayListPlacement;
|
|
11
11
|
interface?: InterfacePlacement<TInterfacePlacementLength>;
|
|
12
12
|
volumeSlider?: VolumeSliderPlacement;
|
|
13
|
+
speedSelector?: SpeedSelectorPlacement;
|
|
13
14
|
};
|
|
14
15
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './TransportControls';
|
|
2
|
+
export * from './TransportControls/PlayBtn';
|
|
3
|
+
export * from './TransportControls/PrevBtn';
|
|
4
|
+
export * from './TransportControls/NextBtn';
|
|
4
5
|
export * from './RepeatTypeBtn';
|
|
5
6
|
export * from './VolumeIcon';
|
package/dist/types/components/AudioPlayer/Interface/Controller/Drawer/SortablePlayList/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
|
|
2
|
+
import { GridItemLayoutProps } from '../../../../../Grid';
|
|
3
|
+
export interface SortablePlayListProps extends GridItemLayoutProps {
|
|
4
|
+
initialExpanded?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const SortablePlayList: FC<SortablePlayListProps>;
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
import { GridItemLayoutProps } from '../../../../../Grid';
|
|
1
2
|
import { FC } from 'react';
|
|
2
|
-
export
|
|
3
|
+
export type ProgressType = "bar" | "waveform";
|
|
4
|
+
export interface ProgressProps extends GridItemLayoutProps {
|
|
5
|
+
/**
|
|
6
|
+
* Override which progress renderer to show. When omitted, falls back to
|
|
7
|
+
* `activeUI.progress`. Used when the preset is disabled but the compound
|
|
8
|
+
* `<AudioPlayer.Progress />` is still placed explicitly — without this,
|
|
9
|
+
* the component would render an empty grid slot.
|
|
10
|
+
*/
|
|
11
|
+
type?: ProgressType;
|
|
12
|
+
}
|
|
13
|
+
export declare const Progress: FC<ProgressProps>;
|
package/dist/types/components/AudioPlayer/Interface/Controller/SpeedSelector/SpeedSelector.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { GridItemLayoutProps } from '../../../../Grid';
|
|
3
|
+
import { SpeedSelectorPlacement } from '../../../Context/StateContext';
|
|
4
|
+
export interface SpeedSelectorProps extends GridItemLayoutProps {
|
|
5
|
+
options?: number[];
|
|
6
|
+
formatRate?: (rate: number) => string;
|
|
7
|
+
triggerType?: "click" | "hover";
|
|
8
|
+
placement?: SpeedSelectorPlacement;
|
|
9
|
+
}
|
|
10
|
+
export declare const SpeedSelector: FC<SpeedSelectorProps>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
|
|
2
|
+
import { GridItemLayoutProps } from '../../../../../Grid';
|
|
3
|
+
import { VolumeSliderPlacement } from '../../../../Context/StateContext';
|
|
4
|
+
export interface VolumeProps extends GridItemLayoutProps {
|
|
5
|
+
triggerType?: "click" | "hover";
|
|
6
|
+
placement?: VolumeSliderPlacement;
|
|
7
|
+
}
|
|
8
|
+
export declare const Volume: FC<VolumeProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ActiveUI } from '../../Context/StateContext';
|
|
3
|
+
export type ActiveUIKey = keyof ActiveUI;
|
|
4
|
+
export interface SlotMeta {
|
|
5
|
+
displayName: string;
|
|
6
|
+
activeUIKey: ActiveUIKey;
|
|
7
|
+
}
|
|
8
|
+
export declare const compoundSlotMetaMap: Record<string, SlotMeta>;
|
|
9
|
+
export declare function isPresetActive(activeUI: ActiveUI, key: ActiveUIKey): boolean;
|
|
10
|
+
export declare function resolveSlotKey(child: ReactElement): string | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ActiveUI } from '../../Context/StateContext';
|
|
3
|
+
export interface DuplicateSlotWarningArgs {
|
|
4
|
+
compoundChildren: ReactElement[];
|
|
5
|
+
activeUI: ActiveUI;
|
|
6
|
+
}
|
|
7
|
+
export declare function useDuplicateSlotWarning({ compoundChildren, activeUI, }: DuplicateSlotWarningArgs): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const playListPortalContext: import('react').Context<HTMLDivElement | null>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ActiveUI, InterfacePlacement } from '../../Context';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
export declare const useGridTemplate: (activeUI: ActiveUI, templateArea: InterfacePlacement["templateArea"] | undefined, customComponentsArea?: InterfacePlacement["customComponentsArea"], compoundChildren?: ReactElement[]) => readonly [string[], string[]];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DropdownContentPlacement } from '../../../Dropdown';
|
|
2
|
+
type TriggerType = "click" | "hover";
|
|
3
|
+
interface UseResolvedDropdownPropsParams {
|
|
4
|
+
triggerType: TriggerType | undefined;
|
|
5
|
+
placement: DropdownContentPlacement | undefined;
|
|
6
|
+
contextPlacement: DropdownContentPlacement | undefined;
|
|
7
|
+
triggerRef: React.RefObject<HTMLElement>;
|
|
8
|
+
defaults: {
|
|
9
|
+
triggerType: TriggerType;
|
|
10
|
+
placement: DropdownContentPlacement;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const useResolvedDropdownProps: ({ triggerType, placement, contextPlacement, triggerRef, defaults, }: UseResolvedDropdownPropsParams) => {
|
|
14
|
+
triggerType: TriggerType;
|
|
15
|
+
placement: DropdownContentPlacement;
|
|
16
|
+
contentRole: "dialog" | "tooltip";
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioPlayerStateProviderProps,
|
|
1
|
+
import { AudioPlayerStateProviderProps, DEFAULT_INTERFACE_GRID_BOUND } from '../Context';
|
|
2
2
|
export interface AudioPlayerProps<TInterfacePlacementLength extends number> extends AudioPlayerStateProviderProps<TInterfacePlacementLength> {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
audioRef?: React.MutableRefObject<HTMLAudioElement>;
|
|
@@ -9,4 +9,4 @@ export interface AudioPlayerProps<TInterfacePlacementLength extends number> exte
|
|
|
9
9
|
*/
|
|
10
10
|
colorScheme?: "light" | "dark";
|
|
11
11
|
}
|
|
12
|
-
export declare const AudioPlayer: <TInterfacePlacementLength extends number = typeof
|
|
12
|
+
export declare const AudioPlayer: <TInterfacePlacementLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND>({ audioRef, children, ...restProps }: AudioPlayerProps<TInterfacePlacementLength>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_INTERFACE_GRID_BOUND, AudioPlayerStateProviderProps } from '../Context';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
interface AudioPlayerStateProviderOwnProps<T extends number = number> extends AudioPlayerStateProviderProps<T> {
|
|
4
4
|
colorScheme?: "light" | "dark";
|
|
5
5
|
}
|
|
6
|
-
export declare const AudioPlayerStateProvider: <TInterfacePlacementLength extends number = typeof
|
|
6
|
+
export declare const AudioPlayerStateProvider: <TInterfacePlacementLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND>({ children, colorScheme, ...initProps }: PropsWithChildren<AudioPlayerStateProviderOwnProps<TInterfacePlacementLength>>) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
import { AudioPlayerContainerProps } from './Container';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_INTERFACE_GRID_BOUND } from './Context';
|
|
3
|
+
import { CustomComponent } from './Interface/CustomComponent';
|
|
4
|
+
import { PlayListEmpty } from './Interface/PlayListEmpty';
|
|
3
5
|
import { AudioPlayerProps } from './Player';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
import { Progress } from './Interface/Controller/Input';
|
|
7
|
+
import { Volume } from './Interface/Controller/Tooltip';
|
|
8
|
+
import { SortablePlayList } from './Interface/Controller/Drawer';
|
|
9
|
+
import { SpeedSelector } from './Interface/Controller/SpeedSelector';
|
|
10
|
+
import { TransportControls, RepeatTypeBtn } from './Interface/Controller/Button';
|
|
11
|
+
import { Artwork } from './Interface/Information/Artwork';
|
|
12
|
+
import { TrackInfo } from './Interface/Information/TrackInfo';
|
|
13
|
+
import { TrackTime } from './Interface/Information/TrackTime';
|
|
14
|
+
export type RMAudioPlayerProps<TInterfacePlacementLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND> = AudioPlayerProps<TInterfacePlacementLength> & AudioPlayerContainerProps;
|
|
15
|
+
declare function AudioPlayerWithProviders<TInterfacePlacementLength extends number = typeof DEFAULT_INTERFACE_GRID_BOUND>({ rootContainerProps, ...audioPlayProps }: RMAudioPlayerProps<TInterfacePlacementLength>): import("react/jsx-runtime").JSX.Element;
|
|
6
16
|
declare namespace AudioPlayerWithProviders {
|
|
7
17
|
var displayName: string;
|
|
8
|
-
var CustomComponent: import("react").FC<import("./Interface/CustomComponent").CustomComponentProps>;
|
|
9
18
|
}
|
|
10
|
-
|
|
19
|
+
type AudioPlayerComponent = typeof AudioPlayerWithProviders & {
|
|
20
|
+
Progress: typeof Progress;
|
|
21
|
+
Volume: typeof Volume;
|
|
22
|
+
PlayList: typeof SortablePlayList;
|
|
23
|
+
PlayListEmpty: typeof PlayListEmpty;
|
|
24
|
+
PlayButton: typeof TransportControls;
|
|
25
|
+
RepeatButton: typeof RepeatTypeBtn;
|
|
26
|
+
SpeedSelector: typeof SpeedSelector;
|
|
27
|
+
Artwork: typeof Artwork;
|
|
28
|
+
TrackInfo: typeof TrackInfo;
|
|
29
|
+
TrackTime: typeof TrackTime;
|
|
30
|
+
CustomComponent: typeof CustomComponent;
|
|
31
|
+
};
|
|
32
|
+
declare const AudioPlayerCompound: AudioPlayerComponent;
|
|
33
|
+
export default AudioPlayerCompound;
|
|
@@ -5,6 +5,7 @@ import { DrawerContent } from './DrawerContent';
|
|
|
5
5
|
export interface DrawerProps extends Omit<Partial<DrawerContext>, "setIsOpen"> {
|
|
6
6
|
outboundClickActive?: boolean;
|
|
7
7
|
placement?: "bottom" | "top";
|
|
8
|
+
initialOpen?: boolean;
|
|
8
9
|
}
|
|
9
10
|
declare const Drawer: FC<PropsWithChildren<DrawerProps>>;
|
|
10
11
|
type DrawerComponent = typeof Drawer & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, HTMLAttributes } from 'react';
|
|
2
|
-
export interface
|
|
2
|
+
export interface GridItemLayoutProps {
|
|
3
3
|
gridArea?: string;
|
|
4
4
|
width?: CSSProperties["width"];
|
|
5
5
|
visible?: boolean;
|
|
@@ -7,4 +7,5 @@ export interface GridItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
justifySelf?: CSSProperties["justifySelf"];
|
|
8
8
|
padding?: CSSProperties["padding"];
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type GridItemProps = GridItemLayoutProps & HTMLAttributes<HTMLDivElement>;
|
|
11
|
+
export declare const GridItem: import('react').ForwardRefExoticComponent<GridItemLayoutProps & HTMLAttributes<HTMLDivElement> & import('react').RefAttributes<HTMLDivElement>>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
export default
|
|
1
|
+
import { default as AudioPlayer } from './components/AudioPlayer';
|
|
2
|
+
export default AudioPlayer;
|
|
3
3
|
export * from './components/AudioPlayer';
|
|
4
4
|
export * from './components/AudioPlayer/Context';
|
|
5
5
|
export * from './components/AudioPlayer/Player';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
|
-
/** true when running in a browser environment */
|
|
3
2
|
export declare const isBrowser: boolean;
|
|
4
|
-
/** useLayoutEffect that falls back to useEffect during SSR */
|
|
5
3
|
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
package/llms.txt
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# React Modern Audio Player
|
|
2
|
+
|
|
3
|
+
> Modern, customizable React audio player with waveform visualization, drag-and-drop playlist, WAI-ARIA accessibility, TypeScript-first API, and Next.js App Router (Server Components) support. Published on npm as `react-modern-audio-player`.
|
|
4
|
+
|
|
5
|
+
This library exports a single default `<AudioPlayer>` component driven by declarative props, plus a compound `<AudioPlayer.CustomComponent>` and a family of `useAudioPlayer*` hooks for programmatic control. Runtime requirements: React 18 or higher, `react-dom` 18 or higher. `wavesurfer.js` 6.x is an internal dependency (no peer install needed). The library entry point ships a `'use client'` directive so it can be imported directly from Next.js Server Components; hook consumers and compound children must themselves be Client Components.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install react-modern-audio-player
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import AudioPlayer from "react-modern-audio-player";
|
|
17
|
+
|
|
18
|
+
const playList = [
|
|
19
|
+
{ id: 1, src: "audio.mp3", name: "Track 1", writer: "Artist", img: "cover.jpg" },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export default function Page() {
|
|
23
|
+
return <AudioPlayer playList={playList} />;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Core API
|
|
28
|
+
|
|
29
|
+
- `AudioPlayer` (default export) — accepts `playList`, `audioInitialState`, `activeUI`, `placement`, `colorScheme`, `customIcons`, `coverImgsCss`, `rootContainerProps`, `audioRef`.
|
|
30
|
+
- `AudioPlayer.CustomComponent` — compound child that slots custom nodes into a named grid area (`placement.interface.customComponentsArea`). Requires `'use client'` in the consumer file.
|
|
31
|
+
- `useAudioPlayer()` — control hook. Returns `{ isPlaying, volume, currentTime, duration, repeatType, muted, currentTrack, currentIndex, playList, play, pause, togglePlay, next, prev, seek, setVolume, toggleMute, setTrack }`.
|
|
32
|
+
- Sub-hooks for minimal re-renders: `useAudioPlayerPlayback`, `useAudioPlayerTrack`, `useAudioPlayerVolume`, `useAudioPlayerTime`, `useAudioPlayerElement`.
|
|
33
|
+
- Low-level context hooks (advanced): `usePlaybackContext`, `useTrackContext`, `useUIContext`, `useResourceContext`.
|
|
34
|
+
|
|
35
|
+
## Key types
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
type AudioData = {
|
|
39
|
+
src: string;
|
|
40
|
+
id: number;
|
|
41
|
+
name?: string;
|
|
42
|
+
writer?: string;
|
|
43
|
+
img?: string;
|
|
44
|
+
description?: string | ReactNode;
|
|
45
|
+
customTrackInfo?: string | ReactNode;
|
|
46
|
+
};
|
|
47
|
+
type PlayList = AudioData[];
|
|
48
|
+
type RepeatType = "ALL" | "ONE" | "NONE" | "SHUFFLE";
|
|
49
|
+
type ProgressUI = "waveform" | "bar" | false;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Docs
|
|
53
|
+
|
|
54
|
+
- [README.md](https://unpkg.com/react-modern-audio-player/README.md): full reference — props tables, theme CSS variables, grid placement syntax, keyboard shortcuts, common integration pitfalls ("Gotchas"), and end-to-end examples.
|
|
55
|
+
- [CHANGELOG.md](https://raw.githubusercontent.com/slash9494/react-modern-audio-player/main/package/CHANGELOG.md): version history, breaking changes, migration notes (served from GitHub — not shipped in the npm tarball).
|
|
56
|
+
|
|
57
|
+
## Optional
|
|
58
|
+
|
|
59
|
+
- [GitHub repository](https://github.com/slash9494/react-modern-audio-player)
|
|
60
|
+
- [CodeSandbox demo](https://codesandbox.io/p/sandbox/basic-nfrpfq)
|
|
61
|
+
- [npm page](https://www.npmjs.com/package/react-modern-audio-player)
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-modern-audio-player",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Modern, customizable React audio player with waveform visualization, drag-and-drop playlist, WAI-ARIA accessibility, TypeScript-first API, and Next.js App Router (Server Components) support.",
|
|
4
5
|
"author": {
|
|
5
6
|
"name": "MAXX",
|
|
6
7
|
"email": "slash9494@gmail.com",
|
|
@@ -12,7 +13,8 @@
|
|
|
12
13
|
"esnext": "dist/index.es.js",
|
|
13
14
|
"typings": "dist/types/index.d.ts",
|
|
14
15
|
"files": [
|
|
15
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"llms.txt"
|
|
16
18
|
],
|
|
17
19
|
"license": "MIT",
|
|
18
20
|
"repository": {
|
package/dist/types/components/AudioPlayer/Interface/Controller/Tooltip/Volume/useVolume.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { VolumeSliderPlacement } from '../../../../Context';
|
|
2
|
-
export declare const useVolumeSliderPlacement: ({ triggerRef, initialState, }: {
|
|
3
|
-
triggerRef: React.RefObject<HTMLElement>;
|
|
4
|
-
initialState: VolumeSliderPlacement;
|
|
5
|
-
}) => import('../../../../../Dropdown').DropdownContentPlacement;
|