Skip to content

Commit

Permalink
fix: Lyrics highlight disabled due to blinking
Browse files Browse the repository at this point in the history
  • Loading branch information
khaled-0 committed Nov 29, 2024
1 parent 7d388c5 commit 1dafaf0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions lib/app/player/components/lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _LyricsState extends State<Lyrics> with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
return Card(
return Card.filled(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
child: ValueListenableBuilder(
valueListenable: context.read<PlayerProvider>().nowPlaying,
Expand Down Expand Up @@ -73,7 +73,7 @@ class _LyricsState extends State<Lyrics> with AutomaticKeepAliveClientMixin {
position: playerPosition,
playing: playing,
emptyBuilder: () => const Center(child: Text("............")),
lyricUi: _LyricsUI(Theme.of(context).colorScheme.primary),
lyricUi: _LyricsUI(context),
);
}

Expand All @@ -93,10 +93,19 @@ class _LyricsState extends State<Lyrics> with AutomaticKeepAliveClientMixin {
}

class _LyricsUI extends UINetease {
final Color highlightColor;
final BuildContext context;

_LyricsUI(this.highlightColor);
_LyricsUI(this.context);

@override
Color getLyricHightlightColor() => highlightColor;
Color getLyricHightlightColor() => Theme.of(context).colorScheme.primary;

@override
bool get highlight => false;

@override
TextStyle getPlayingMainTextStyle() => Theme.of(context).textTheme.titleLarge!;

@override
TextStyle getOtherMainTextStyle() => Theme.of(context).textTheme.bodyMedium!;
}
2 changes: 1 addition & 1 deletion lib/clients/yt_media_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class YTMediaClient implements BaseMediaClient {
return trackManifest.captions.map((e) {
// FIXME: Don't do hacks
final timestamp = (e.offset).toString().substring(2, 10);
final lyric = e.text.replaceAll("\n", "\n[$timestamp]");
final lyric = e.text.replaceAll("\n", " ");

return "[$timestamp]$lyric";
}).toList();
Expand Down

0 comments on commit 1dafaf0

Please sign in to comment.