Skip to content

Commit

Permalink
Bug fix - 200 - enable seek gesture in paused mode
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshuGandhiSimform committed Oct 15, 2024
1 parent fb0612c commit fab7640
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/src/audio_file_waveforms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,19 @@ class _AudioFileWaveformsState extends State<AudioFileWaveforms>
_proportion = details.localPosition.dx / widget.size.width;
var seekPosition = widget.playerController.maxDuration * _proportion;

widget.playerController.seekTo(seekPosition.toInt());
widget.playerController.seekTo(
seekPosition.toInt(),
);
}

/// This method handles tap seek gesture
void _handleScrubberSeekStart(TapUpDetails details) {
_proportion = details.localPosition.dx / widget.size.width;
var seekPosition = widget.playerController.maxDuration * _proportion;

widget.playerController.seekTo(seekPosition.toInt());
widget.playerController.seekTo(
seekPosition.toInt(),
);
}

///This method handles horizontal scrolling of the wave
Expand Down Expand Up @@ -339,6 +343,7 @@ class _AudioFileWaveformsState extends State<AudioFileWaveforms>
_proportion = (details.delta.dx - start) /
(_waveformData.length * widget.playerWaveStyle.spacing);
}

if (mounted) setState(() {});
}

Expand Down
7 changes: 3 additions & 4 deletions lib/src/controllers/player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,9 @@ class PlayerController extends ChangeNotifier {
/// Minimum Android [O] is required to use this function
/// otherwise nothing happens.
Future<void> seekTo(int progress) async {
if (progress < 0) return;
if (_playerState == PlayerState.playing) {
await AudioWaveformsInterface.instance.seekTo(playerKey, progress);
}
if (progress < 0 || _playerState.isStopped) return;

await AudioWaveformsInterface.instance.seekTo(playerKey, progress);
}

/// Release any resources taken by this controller. Disposing this
Expand Down

0 comments on commit fab7640

Please sign in to comment.