flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

[HELP]: I can't play paused recording in flutter web

Open mihailovukojicic opened this issue 1 year ago • 10 comments

I need Help for :

  • Using the API

Here is my question :

I can't play paused recording.

LOGS

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 1145:5      _stop
│ #1   packages/flutter_sound/public/flutter_sound_player.dart 1144:21     [_stop]
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 FS:---> _stop 
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 313:5                     stopPlayerCompleted
│ #1   packages/flutter_sound_web/flutter_sound_player_web.dart 159:7                    <fn>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 ---> stopPlayerCompleted: true
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 328:5                     stopPlayerCompleted
│ #1   packages/flutter_sound_web/flutter_sound_player_web.dart 159:7                    <fn>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 <--- stopPlayerCompleted: true
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 1172:5      _stop
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 FS:<--- _stop 
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 377:5       log
│ #1   packages/flutter_sound_web/flutter_sound_player_web.dart 326:13     startPlayer
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 startPlayer FromURI : audio_record.mp4
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 847:5       _startPlayer
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 FS:<--- startPlayer 
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ #0   packages/flutter_sound/public/flutter_sound_player.dart 377:5                     log
│ #1   packages/flutter_sound_web/flutter_sound_player_web.dart 168:7                    <fn>
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 💡 onloaderror

Method for starting the playback

void _startPlayback() {
    setState(() {
      isRecordingPlayed = true;
    });
    _mPlayer.setSubscriptionDuration(const Duration(milliseconds: 100));
    _mPlayer.onProgress!.listen((event) {
      setState(() {
        playbackProgress =
            event.position.inMilliseconds / event.duration.inMilliseconds;
      });
    });

    _mPlayer.startPlayer(
      fromURI: _mPath,
      whenFinished: () => setState(() {
        playbackProgress = 1.0;
        isRecordingPlayed = false;
      }),
    );
  }

mihailovukojicic avatar Jan 09 '25 14:01 mihailovukojicic

Are you sure that _mPath is a valid file that is accessible and has a valid codec. You should launch your app through Chrome, and look to the chrome debugger. You may have a more detailed error message.

Larpoux avatar Jan 09 '25 17:01 Larpoux

When I go with the flow

  1. Start recording
  2. Stop recording
  3. Play recording from the method above

Everything is working like a charm, only when I pause the recording, it won't play the current recording that is paused.

mihailovukojicic avatar Jan 10 '25 07:01 mihailovukojicic

Do you record to File, to Buffer or to Stream ?

Larpoux avatar Jan 10 '25 08:01 Larpoux

Screenshot 2025-01-10 at 09 18 06 to file.

mihailovukojicic avatar Jan 10 '25 08:01 mihailovukojicic

You are recording to the _mPath file, with the _mCodec codec. The file is invalid until it is stopped.

Larpoux avatar Jan 10 '25 08:01 Larpoux

So I have to change the logic to use toStream to process recording in real time?

mihailovukojicic avatar Jan 10 '25 08:01 mihailovukojicic

Yes, you will not have this issue if you record to stream

Larpoux avatar Jan 10 '25 08:01 Larpoux

Thank you for the quick and kind response!

mihailovukojicic avatar Jan 10 '25 08:01 mihailovukojicic

Is the toStream method working in flutter web for flutter_sound: 9.4.7?

mihailovukojicic avatar Jan 10 '25 08:01 mihailovukojicic

No, not yet. Just in the future v10.0. But I am going to try to downport this feature to the v9.x because v10 will not be released soon. I will post something on this thread later.

Larpoux avatar Jan 10 '25 09:01 Larpoux