Compare commits
5 Commits
v0.1.6.34
...
71c7f2aab5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71c7f2aab5 | ||
|
|
096682929d | ||
|
|
cebdf7a5a2 | ||
|
|
afbdb74516 | ||
|
|
9372264174 |
@@ -24,12 +24,12 @@ COPY --from=deps /app/node_modules ./node_modules
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Extract version: use build arg if provided, otherwise get from git, fallback to package.json
|
# Extract version: use build arg if provided, otherwise get from git, fallback to package.json
|
||||||
|
# Only use tags that are reachable from the current commit to ensure version matches the code
|
||||||
RUN if [ -n "$APP_VERSION" ]; then \
|
RUN if [ -n "$APP_VERSION" ]; then \
|
||||||
echo "$APP_VERSION" > /tmp/version.txt; \
|
echo "$APP_VERSION" > /tmp/version.txt; \
|
||||||
else \
|
else \
|
||||||
(git describe --tags --exact-match 2>/dev/null || \
|
(git describe --tags --exact-match 2>/dev/null || \
|
||||||
git describe --tags --abbrev=0 2>/dev/null || \
|
git describe --tags --abbrev=0 2>/dev/null || \
|
||||||
git tag --sort=-version:refname | head -1 2>/dev/null || \
|
|
||||||
(grep -o '"version": "[^"]*"' package.json 2>/dev/null | cut -d'"' -f4 | sed 's/^/v/') || \
|
(grep -o '"version": "[^"]*"' package.json 2>/dev/null | cut -d'"' -f4 | sed 's/^/v/') || \
|
||||||
echo "dev") > /tmp/version.txt; \
|
echo "dev") > /tmp/version.txt; \
|
||||||
fi && \
|
fi && \
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
const [progress, setProgress] = useState(0);
|
const [progress, setProgress] = useState(0);
|
||||||
const [hasPlayedOnce, setHasPlayedOnce] = useState(false);
|
const [hasPlayedOnce, setHasPlayedOnce] = useState(false);
|
||||||
|
|
||||||
const [processedSrc, setProcessedSrc] = useState(src);
|
const [processedSrc, setProcessedSrc] = useState<string | null>(null);
|
||||||
const [processedUnlockedSeconds, setProcessedUnlockedSeconds] = useState(unlockedSeconds);
|
const [processedUnlockedSeconds, setProcessedUnlockedSeconds] = useState<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('[AudioPlayer] MOUNTED');
|
console.log('[AudioPlayer] MOUNTED');
|
||||||
@@ -41,7 +41,7 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
let startPos = startTime;
|
let startPos = startTime;
|
||||||
|
|
||||||
// If same song but more time unlocked, start from where previous segment ended
|
// If same song but more time unlocked, start from where previous segment ended
|
||||||
if (src === processedSrc && unlockedSeconds > processedUnlockedSeconds) {
|
if (processedSrc !== null && src === processedSrc && processedUnlockedSeconds !== null && unlockedSeconds > processedUnlockedSeconds) {
|
||||||
startPos = startTime + processedUnlockedSeconds;
|
startPos = startTime + processedUnlockedSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,8 +62,11 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
const initialPercent = unlockedSeconds > 0 ? (initialElapsed / unlockedSeconds) * 100 : 0;
|
const initialPercent = unlockedSeconds > 0 ? (initialElapsed / unlockedSeconds) * 100 : 0;
|
||||||
setProgress(Math.min(initialPercent, 100));
|
setProgress(Math.min(initialPercent, 100));
|
||||||
|
|
||||||
setHasPlayedOnce(false); // Reset for new segment
|
// Only reset hasPlayedOnce if the song changed, not if just more time was unlocked
|
||||||
onHasPlayedChange?.(false); // Notify parent
|
if (processedSrc !== null && src !== processedSrc) {
|
||||||
|
setHasPlayedOnce(false); // Reset for new song
|
||||||
|
onHasPlayedChange?.(false); // Notify parent
|
||||||
|
}
|
||||||
|
|
||||||
// Update processed state
|
// Update processed state
|
||||||
setProcessedSrc(src);
|
setProcessedSrc(src);
|
||||||
@@ -72,22 +75,31 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
if (autoPlay) {
|
if (autoPlay) {
|
||||||
// Delay play slightly to ensure currentTime sticks
|
// Delay play slightly to ensure currentTime sticks
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const playPromise = audioRef.current?.play();
|
if (audioRef.current) {
|
||||||
if (playPromise !== undefined) {
|
// Use startPos (which may be startTime + processedUnlockedSeconds if more time was unlocked)
|
||||||
playPromise
|
// instead of always using startTime
|
||||||
.then(() => {
|
audioRef.current.currentTime = startPos;
|
||||||
setIsPlaying(true);
|
const playPromise = audioRef.current.play();
|
||||||
onPlay?.();
|
if (playPromise !== undefined) {
|
||||||
setHasPlayedOnce(true);
|
playPromise
|
||||||
onHasPlayedChange?.(true); // Notify parent
|
.then(() => {
|
||||||
})
|
setIsPlaying(true);
|
||||||
.catch(error => {
|
onPlay?.();
|
||||||
console.log("Autoplay prevented:", error);
|
setHasPlayedOnce(true);
|
||||||
setIsPlaying(false);
|
onHasPlayedChange?.(true); // Notify parent
|
||||||
});
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log("Autoplay prevented:", error);
|
||||||
|
setIsPlaying(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 150);
|
}, 150);
|
||||||
}
|
}
|
||||||
|
} else if (startTime !== undefined && audioRef.current.currentTime < startTime) {
|
||||||
|
// If startTime is set and currentTime is before it, reset to startTime
|
||||||
|
// This handles the case where the audio element was reset or reloaded
|
||||||
|
audioRef.current.currentTime = startTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [src, unlockedSeconds, startTime, autoPlay, processedSrc, processedUnlockedSeconds]);
|
}, [src, unlockedSeconds, startTime, autoPlay, processedSrc, processedUnlockedSeconds]);
|
||||||
@@ -97,6 +109,16 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
play: () => {
|
play: () => {
|
||||||
if (!audioRef.current) return;
|
if (!audioRef.current) return;
|
||||||
|
|
||||||
|
// Check if we need to reset to startTime
|
||||||
|
const current = audioRef.current.currentTime;
|
||||||
|
const elapsed = current - startTime;
|
||||||
|
|
||||||
|
// Reset if: never played before, current position is before startTime, or we've exceeded the unlocked segment
|
||||||
|
if (!hasPlayedOnce || current < startTime || elapsed >= unlockedSeconds) {
|
||||||
|
// Reset to start of segment
|
||||||
|
audioRef.current.currentTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
const playPromise = audioRef.current.play();
|
const playPromise = audioRef.current.play();
|
||||||
if (playPromise !== undefined) {
|
if (playPromise !== undefined) {
|
||||||
playPromise
|
playPromise
|
||||||
@@ -121,8 +143,20 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
|
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
audioRef.current.pause();
|
audioRef.current.pause();
|
||||||
|
setIsPlaying(false);
|
||||||
} else {
|
} else {
|
||||||
|
// Check if we need to reset to startTime
|
||||||
|
const current = audioRef.current.currentTime;
|
||||||
|
const elapsed = current - startTime;
|
||||||
|
|
||||||
|
// Reset if: never played before, current position is before startTime, or we've exceeded the unlocked segment
|
||||||
|
if (!hasPlayedOnce || current < startTime || elapsed >= unlockedSeconds) {
|
||||||
|
// Reset to start of segment
|
||||||
|
audioRef.current.currentTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
audioRef.current.play();
|
audioRef.current.play();
|
||||||
|
setIsPlaying(true);
|
||||||
onPlay?.();
|
onPlay?.();
|
||||||
|
|
||||||
if (hasPlayedOnce) {
|
if (hasPlayedOnce) {
|
||||||
@@ -132,7 +166,6 @@ const AudioPlayer = forwardRef<AudioPlayerRef, AudioPlayerProps>(({ src, unlocke
|
|||||||
onHasPlayedChange?.(true); // Notify parent
|
onHasPlayedChange?.(true); // Notify parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setIsPlaying(!isPlaying);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTimeUpdate = () => {
|
const handleTimeUpdate = () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hoerdle",
|
"name": "hoerdle",
|
||||||
"version": "0.1.6.34",
|
"version": "0.1.6.36",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user