flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

Why is the file type 'video/mp4' and not 'audio/mpeg'?

Open RohithKilaparthi opened this issue 6 years ago • 6 comments

We are trying to record a voice from android and post it to Firebase Storage. When we are trying to play the voice in android, it gets played well, but when it is on Firebase, it fails to play. When I investigated, I saw that the file type is 'video/mp4' and not 'audio/mpeg'.

Audio uploaded through Flutter Sound: https://firebasestorage.googleapis.com/v0/b/logs-9bffe.appspot.com/o/3RXe1qHGQHbTr5QAv9XH%2FXydYMyvrTT5U68TDL1fs%2F51fac690-0e85-11ea-87d6-517c1c72d09c-2019-11-24%2012%3A10%3A35.698798.mp3?alt=media&token=85e7e99e-5016-480a-b2c7-f7d8158bffe2

Normal Audio: https://firebasestorage.googleapis.com/v0/b/logs-9bffe.appspot.com/o/3RXe1qHGQHbTr5QAv9XH%2FXydYMyvrTT5U68TDL1fs%2Ftest.mp3?alt=media&token=f1860a83-5d5f-4144-89cd-6527904d2b48

Can you look into the issue and help us a way through?

RohithKilaparthi avatar Nov 24 '19 09:11 RohithKilaparthi

This is the code snippet we are using:

 void startRecorder(formDetail) async {
    try {
      DateTime timeStamp = DateTime.now();
      String fileName = Uuid().v1() + "-" + timeStamp.toString();
      fileName = fileName + (Platform.isIOS ? '.m4a' : '.mp3');
      setResponseField(formDetail, fileName);
      String path = await flutterSound.startRecorder(fileName);
      _recorderSubscription =
          flutterSound.onRecorderStateChanged.listen((e) {});
      _dbPeakSubscription =
          flutterSound.onRecorderDbPeakChanged.listen((value) {
        print("got update -> $value");
        setState(() {
          // this._dbLevel = value;
        });
      });

      this.setState(() {
        this._isRecording = true;
        setResponseField(formDetail, path);
      });
    } catch (err) {
      print('startRecorder error: $err');
    }
  }

  void stopRecorder(formDetail) async {
    try {
      String result = await flutterSound.stopRecorder();
      String path = responses[formDetail.field];
      var obj = {
        "siteId": site.siteId.toString(),
        "formId": form.formId.toString(),
        "field": formDetail.field.toString()
      };
      print(path);
      if (_recorderSubscription != null) {
        _recorderSubscription.cancel();
        _recorderSubscription = null;
      }
      if (_dbPeakSubscription != null) {
        _dbPeakSubscription.cancel();
        _dbPeakSubscription = null;
      }

      this.setState(() {
        this._isRecording = false;
      });
      File audioFile = File(path);
      List paths = path.split("/");
      uploadFile(audioFile, paths[paths.length - 1], obj);
      setResponseField(formDetail, paths[paths.length - 1]);
    } catch (err) {
      print('stopRecorder error: $err');
    }
  }

RohithKilaparthi avatar Nov 24 '19 09:11 RohithKilaparthi

@hyochan can you please check and provide an update?

RohithKilaparthi avatar Nov 28 '19 12:11 RohithKilaparthi

I think it is related to some other issues such as this. Try to use ffmpeg making cloud function via firebase.

hyochan avatar Dec 07 '19 14:12 hyochan

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.

github-actions[bot] avatar Mar 07 '20 00:03 github-actions[bot]

Hello, any solution regarding this topic?? I'm getting same issue, @RohithKilaparthi did you find anything?

sergiocasero avatar Feb 09 '21 10:02 sergiocasero

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.

github-actions[bot] avatar Dec 23 '23 01:12 github-actions[bot]