Skip to content

Commit

Permalink
[*] fixed adjust lyric playing speed not work
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Jun 1, 2024
1 parent 520d322 commit 50b0508
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion lib/models/player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class PlayerController extends GetxController {
if (song.audioLocation == AudioLocation.asset) {
src = AssetSource(song.audioPath);
} else if (song.audioLocation == AudioLocation.local) {
log.d(song.audioPath);
if (await File(song.audioPath).exists()) {
src = DeviceFileSource(song.audioPath);
} else {
Expand Down
18 changes: 10 additions & 8 deletions lib/pages/song.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class _SongPageState extends State<SongPage> {
);
}

void showAdjustLyricSpeedOverlay(BuildContext context, Song song) {
void showAdjustLyricSpeedOverlay(BuildContext context) {
OverlayState overlayState = Overlay.of(context);
overlayEntry = OverlayEntry(
builder: (context) => Positioned(
Expand All @@ -105,7 +105,7 @@ class _SongPageState extends State<SongPage> {
borderRadius: BorderRadius.circular(CTheme.borderRadius * 4),
),
child: Center(
child: buildAdjustLyricSpeed(context, song),
child: buildAdjustLyricSpeed(context),
),
),
),
Expand All @@ -114,12 +114,14 @@ class _SongPageState extends State<SongPage> {
overlayState.insert(overlayEntry!);
}

Widget buildAdjustLyricSpeed(BuildContext context, Song song) {
Widget buildAdjustLyricSpeed(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
onPressed: () async {
final song = playlistController
.playlist[playlistController.currentSongIndex!];
await song.updateLyricTimeOffset(LyricUpdateType.forward);
song.updateLyrics();
songLyricController.updateControllerWithForceUpdateLyricWidget();
Expand All @@ -129,6 +131,8 @@ class _SongPageState extends State<SongPage> {
const SizedBox(width: CTheme.padding * 5),
IconButton(
onPressed: () async {
final song = playlistController
.playlist[playlistController.currentSongIndex!];
await song.updateLyricTimeOffset(LyricUpdateType.reset);
song.updateLyrics();
songLyricController.updateControllerWithForceUpdateLyricWidget();
Expand All @@ -138,6 +142,8 @@ class _SongPageState extends State<SongPage> {
const SizedBox(width: CTheme.padding * 5),
IconButton(
onPressed: () async {
final song = playlistController
.playlist[playlistController.currentSongIndex!];
await song.updateLyricTimeOffset(LyricUpdateType.backword);
song.updateLyrics();
songLyricController.updateControllerWithForceUpdateLyricWidget();
Expand Down Expand Up @@ -524,11 +530,7 @@ class _SongPageState extends State<SongPage> {

if (!isInitShowAdjustLyricSpeedOverlay) {
isInitShowAdjustLyricSpeedOverlay = true;
showAdjustLyricSpeedOverlay(
context,
playlistController
.playlist[playlistController.currentSongIndex!],
);
showAdjustLyricSpeedOverlay(context);
}
},
icon: const Icon(Icons.adjust_rounded),
Expand Down

0 comments on commit 50b0508

Please sign in to comment.