fix: start word fills on time and blur lyrics on iOS

Web fills rewound to the start whenever played before their word, so every
upcoming word filled at once. iOS ignored the blur filter because React
Native draws it only with its SwiftUI filters flag, now turned on at launch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
joshuafhigginsandClaude Opus 5.5 committed 2026-11-20 00:55:49 -05:00 Verified
1 parent 4ad94ba643
commit 654ab53048
5 files changed
+72 -12

No files matched your search

+12 -7
View File
@@ -12,6 +12,7 @@ import Animated, {
Easing, Easing,
useAnimatedStyle, useAnimatedStyle,
useSharedValue, useSharedValue,
withSequence,
withTiming, withTiming,
type SharedValue, type SharedValue,
} from "react-native-reanimated" } from "react-native-reanimated"
@@ -284,13 +285,17 @@ function FilledWords({
useEffect(() => { useEffect(() => {
cancelAnimation(sung) cancelAnimation(sung)
sung.value = time // Jump to the reported time first, so the wipe never runs from a stale one.
if (isPlaying && end > time) { sung.value =
sung.value = withTiming(end, { isPlaying && end > time
duration: (end - time) * 1000, ? withSequence(
easing: Easing.linear, withTiming(time, { duration: 0 }),
}) withTiming(end, {
} duration: (end - time) * 1000,
easing: Easing.linear,
})
)
: time
}, [sung, time, isPlaying, end]) }, [sung, time, isPlaying, end])
return ( return (
@@ -0,0 +1,3 @@
{
"platforms": ["apple"]
}
@@ -0,0 +1,37 @@
// React Native draws `filter: [{ blur }]` on iOS only with its SwiftUI
// filters flag, which the stable release leaves off. This keeps the stable
// flags and turns that one on.
#import <UIKit/UIKit.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/featureflags/ReactNativeFeatureFlagsOverridesOSSStable.h>
using namespace facebook::react;
class SwiftUIFilterFlags : public ReactNativeFeatureFlagsOverridesOSSStable {
public:
bool enableSwiftUIBasedFilters() override {
return true;
}
};
@interface SwiftUIFilters : NSObject
@end
@implementation SwiftUIFilters
+ (void)load
{
// React Native sets its flags once while launching and throws if they were
// set first, so this waits for launch to finish. No views exist yet then.
[NSNotificationCenter.defaultCenter
addObserverForName:UIApplicationDidFinishLaunchingNotification
object:nil
queue:nil
usingBlock:^(NSNotification *notification) {
ReactNativeFeatureFlags::dangerouslyForceOverride(
std::make_unique<SwiftUIFilterFlags>());
}];
}
@end
@@ -0,0 +1,14 @@
Pod::Spec.new do |s|
s.name = 'SwiftUIFilters'
s.version = '1.0.0'
s.summary = 'Turns on React Native view filters like blur on iOS'
s.description = s.summary
s.license = { :type => 'MIT' }
s.author = 'oTunes'
s.homepage = 'https://otunes.abunchofknowitalls.com'
s.platforms = { :ios => '16.4' }
s.source = { :git => '' }
s.static_framework = true
install_modules_dependencies(s)
s.source_files = '**/*.{h,mm}'
end
+6 -5
View File
@@ -183,7 +183,8 @@ const SyncedLine = React.memo(function SyncedLine({
/** /**
* The playing line's words, each filled as far as it has been sung. The * The playing line's words, each filled as far as it has been sung. The
* browser runs the fills; playback updates only correct their drift. * browser runs the fills on the song's timeline (a word's start is its
* delay); playback updates only correct their drift.
*/ */
function FilledWords({ function FilledWords({
words, words,
@@ -200,6 +201,7 @@ function FilledWords({
React.useEffect(() => { React.useEffect(() => {
fills.current = words.map((word, index) => fills.current = words.map((word, index) =>
spans.current[index]?.animate(WORD_FILL_FRAMES, { spans.current[index]?.animate(WORD_FILL_FRAMES, {
delay: word.start * 1000,
duration: Math.max(word.end - word.start, 0.05) * 1000, duration: Math.max(word.end - word.start, 0.05) * 1000,
easing: "linear", easing: "linear",
fill: "both", fill: "both",
@@ -209,15 +211,14 @@ function FilledWords({
}, [words]) }, [words])
React.useEffect(() => { React.useEffect(() => {
const at = time * 1000
fills.current.forEach((fill, index) => { fills.current.forEach((fill, index) => {
if (!fill) return if (!fill) return
const at = (time - words[index].start) * 1000
if (Math.abs(Number(fill.currentTime ?? 0) - at) > FILL_DRIFT_MS) { if (Math.abs(Number(fill.currentTime ?? 0) - at) > FILL_DRIFT_MS) {
fill.currentTime = at fill.currentTime = at
} }
// `play` on a finished fill would rewind it. // `play` on a finished fill would rewind it to the start.
const duration = Number(fill.effect?.getTiming().duration ?? 0) if (isPlaying && time < words[index].end) fill.play()
if (isPlaying && at < duration) fill.play()
else fill.pause() else fill.pause()
}) })
}, [words, time, isPlaying]) }, [words, time, isPlaying])