question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

There is a problem with onRecorderStateChanged on ios

See original GitHub issue

When I first record and play what I just recorded, and then I click on record again, onRecorderStateChanged has a 0 result all the way and cannot be recorded ‘’’ import ‘dart:io’;

import ‘package:chongmeng/constants/constants.dart’; import ‘package:chongmeng/utils/date_utils.dart’; import ‘package:flutter/material.dart’; import ‘package:flutter_sound/flutter_sound_player.dart’; import ‘package:flutter_sound/flutter_sound_recorder.dart’; import ‘package:intl/intl.dart’; import ‘package:path_provider/path_provider.dart’;

class PlayPage extends StatefulWidget { @override _PlayPageState createState() => _PlayPageState(); }

class _PlayPageState extends State<PlayPage> { FlutterSoundPlayer soundPlayer; FlutterSoundRecorder soundRecorder; var recorderSubscription; var result;

@override void initState() { super.initState(); init(); }

init() async { soundPlayer = await FlutterSoundPlayer().initialize(); soundRecorder = await FlutterSoundRecorder().initialize(); }

void _onStartRecord() async { showToast(“_onStartRecord”); Directory tempDir = await getTemporaryDirectory(); File outputFile = File(‘${tempDir.path}/${DateUtils.currentTimeMillis()}.aac’); result = outputFile.path; String a = await soundRecorder.startRecorder(uri: outputFile.path);

recorderSubscription = soundRecorder.onRecorderStateChanged.listen((e) {
  DateTime date =
      new DateTime.fromMillisecondsSinceEpoch(e.currentPosition.toInt());
  String txt = DateFormat('mm:ss:SS', 'en_US').format(date);

// if (txt.contains(“00:02”)) { // _onStopRecord(); // } }); soundRecorder.onRecorderDbPeakChanged.listen((value) { print(“got update -> $value”); }); }

Future<void> _onStopRecord() async { showToast(“_onStopRecord”); print("_onStopRecord "); String localUrl = await soundRecorder.stopRecorder(); if (recorderSubscription != null) { recorderSubscription.cancel(); recorderSubscription = null; } }

@override void dispose() { soundRecorder.release(); soundPlayer.release(); super.dispose(); }

_onStartPlay() async { showToast(“_onStartPlay”); soundPlayer.startPlayer(this.result); }

@override Widget build(BuildContext context) { return Container( child: Column( children: <Widget>[ IconButton( icon: Icon(Icons.record_voice_over), onPressed: () { _onStartRecord(); }, ), Padding( padding: const EdgeInsets.symmetric(vertical: 24), child: RaisedButton( child: Text(“OK”), onPressed: () { _onStopRecord(); }, ), ), IconButton( icon: Icon(Icons.play_arrow), onPressed: () { _onStartPlay(); }, ), ], ), ); } }

‘’’

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Larpouxcommented, May 19, 2020

Hi @Gibsouille ,

could you look to V 4.0.5 and see if better ?

0reactions
Larpouxcommented, May 20, 2020

Hi @zhangruiyu , I am glad that the issue is fixed. I am really sorry for the delay : the problem occurred on real devices and not the simulator. It was not easy for us to debug that.

Good luck, using Flutter Sound. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

There is a problem with onRecorderStateChanged on ios #324
When I first record and play what I just recorded, and then I click on record again, onRecorderStateChanged has a 0 result all...
Read more >
iOS update and restore errors - Apple Support
Learn how to solve iOS update and restore errors. ... "There was a problem downloading the software." "The device isn't eligible for the ......
Read more >
Recording and playing audio in Flutter - wafrat
Once you start recording, flutter_sound records the audio in a file. On Android it's an mp4 file, while on iOS it's an m4a...
Read more >
flutter - Unable to successfully call startRecorder(uri
It seems as if I currently have an issue where, even when I include ... onRecorderStateChanged.listen((e) { DateTime date = new DateTime.
Read more >
iPhone Owners Report More Serious iOS 16 Problems - Forbes
Other than updating to iOS 16.1, there appears to be no obvious trigger for the problem. Affected users report WiFi disconnecting when their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found