Open dizzersee opened 2 years ago
I have the same bug.
I have the same bug
Same bug
Its more clear and effective to upvote/like the question if you face the same issue Instead of commenting the same which leads to cluttering in chat.
I am loading audio from url and on starting player it causes this issue: the position received goes like this 0->0.xx->1.xx->5.xx-> 1.xx -> 2.xx....4.xx->0.xx.... where xx is some decimal value.
Issue in emulator not tested in real device.
pubspec.yaml flutter_sound: ^9.2.13
code:
bool isLoading = true;
bool isPlaying = false;
bool playedFirstTime = false;
bool isPlayerOpened = false;
Duration position = Duration.zero;
Duration duration = Duration.zero;
late StreamSubscription<PlaybackDisposition>? streamSubscription;
@override
void initState() {
super.initState();
initPlayer();
}
@override
void dispose() {
try {
if (isPlayerOpened) {
Future.microtask(() async => await player.closePlayer());
}
streamSubscription?.cancel();
} catch (_) {}
super.dispose();
}
Future<void> initPlayer() async {
await player.openPlayer();
isPlayerOpened = true;
await player.setSubscriptionDuration(const Duration(milliseconds: 10));
streamSubscription = player.onProgress?.listen((event) {
setState(() {
duration = event.duration;
position =
event.position > event.duration ? event.duration : event.position;
});
});
setState(() {
isLoading = false;
});
}
Future<void> playAudio({required String url}) async {
await player.startPlayer(
fromURI: url,
// codec: Codec.mp3,
whenFinished: () => setState(() {
isPlaying = false;
isPlayerOpened = false;
position = Duration.zero;
player.seekToPlayer(position);
}),
);
setState(() {
isPlaying = true;
playedFirstTime = true;
});
}
Future<void> pauseAudio() async {
await player.pausePlayer();
setState(() {
isPlaying = false;
});
}
Future<void> resumeAudio() async {
await player.resumePlayer();
setState(() {
isPlaying = true;
});
}
...
// Widget with slider and timer
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'$minutes:$seconds',
style: simpleText(fontSize: widget.fontSize),
),
SizedBox(
width: widget.spacing,
),
Expanded(
child: SliderTheme(
data: SliderThemeData(
overlayShape: SliderComponentShape.noOverlay,
),
child: Slider(
value: position.inMilliseconds.toDouble(),
min: 0.0,
max: duration.inMilliseconds.toDouble(),
onChangeStart: (double value) {
// player.pausePlayer();
if (isPlayerOpened) {
pauseAudio();
}
},
onChangeEnd: seek,
onChanged: (double value) {
setState(() {
position =
Duration(milliseconds: value.floor());
});
if (isPlayerOpened) {
resumeAudio();
}
},
activeColor: widget.themeColor,
inactiveColor: widget.themeColor.withOpacity(0.3),
),
),
),
Text(
'$durationMinutes:$durationSeconds',
style: simpleText(fontSize: widget.fontSize),
),
],
),
...
Log:
D/EGL_emulation( 5615): app_time_stats: avg=16.57ms min=2.35ms max=38.81ms count=50
D/EGL_emulation( 5615): app_time_stats: avg=23.76ms min=3.49ms max=78.48ms count=42
D/EGL_emulation( 5615): app_time_stats: avg=24.51ms min=9.01ms max=69.10ms count=43
D/EGL_emulation( 5615): app_time_stats: avg=15.57ms min=7.69ms max=23.20ms count=59
I/flutter ( 5615): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 5615): │ #0 new FlutterSoundPlayer (package:flutter_sound/public/flutter_sound_player.dart:132:13)
I/flutter ( 5615): │ #1 new _AudioPlayerState (package:chatezy/common/widgets/new_feed_widget.dart:621:18)
I/flutter ( 5615): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 5615): │ 🐛 ctor: FlutterSoundPlayer()
I/flutter ( 5615): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 5615): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter ( 5615): │ #0 FlutterSoundPlayer._openAudioSession (package:flutter_sound/public/flutter_sound_player.dart:511:13)
I/flutter ( 5615): │ #1 FlutterSoundPlayer.openPlayer.
I am also facing this issue, one thing I noticed it stores the time between pause and resume and that time is shown on the duration Stream. Let's say you took a pause of 10 seconds then the timer resets and it starts from 0 - (time for the pause). And as a result, the timer will start from 00:-10 next time.
Maybe these are the same issue.
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.
I am facing same issue.
Flutter Sound Version : 9.2.13
Severity
Progress of Recorder wrong value on resume
Platforms you faced the error
Android emulator and real device
Describe the bug When I pause and resume the recorder, the progress time jumps to somewhere between 1 and 4 secs, then decreases back to 0 secs, and then increases again, instead of just continuing to increase form where it was before the pause.
The recording itself is made correctly - if I playback it, the pauses and length are correct.
Logs!!!!
Nothing special is put to logs
My code snippets: