start adding payment

This commit is contained in:
Thomas Demirdjian
2025-11-04 14:46:12 +01:00
parent 02a2333a41
commit 4bb083ea46
24 changed files with 3507 additions and 7604 deletions
+20
View File
@@ -84,6 +84,7 @@ const DEFAULT_CONTEXT = {
isLooping: false,
setLooping: noop,
toggleLooping: noop,
getTrackInfo: () => null,
};
export const PlayerContext = createContext(DEFAULT_CONTEXT);
@@ -230,6 +231,7 @@ const PlayerProvider = ({ children }) => {
const autoPlayRef = useRef(false);
const pendingSeekValueRef = useRef(null);
const didJustFinishRef = useRef(false);
const trackInfoRef = useRef({});
const setQueueIndexValue = useCallback((index = -1) => {
const list = queueRef.current;
@@ -401,6 +403,18 @@ const PlayerProvider = ({ children }) => {
durationMs,
};
});
if (currentTrack?.id) {
trackInfoRef.current[currentTrack.id] = {
durationMs:
durationMs > 0
? durationMs
: trackInfoRef.current[currentTrack.id]?.durationMs || 0,
positionMs,
isLoaded,
updatedAt: Date.now(),
};
}
}, [status, currentTrack]);
useEffect(() => {
@@ -614,6 +628,10 @@ const PlayerProvider = ({ children }) => {
const toggleLooping = useCallback(() => {
setIsLooping((prev) => !prev);
}, []);
const getTrackInfo = useCallback((trackId) => {
if (!trackId) return null;
return trackInfoRef.current[trackId] || null;
}, []);
useEffect(() => {
if (!currentTrack?.id) {
@@ -692,6 +710,7 @@ const PlayerProvider = ({ children }) => {
isLooping,
setLooping,
toggleLooping,
getTrackInfo,
}),
[
currentTrack,
@@ -715,6 +734,7 @@ const PlayerProvider = ({ children }) => {
setLooping,
toggleLooping,
setQueue,
getTrackInfo,
]
);