Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
868 stars 567 forks source link

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

Open RohithKilaparthi opened 4 years ago

RohithKilaparthi commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@hyochan can you please check and provide an update?

hyochan commented 4 years ago

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

github-actions[bot] commented 4 years ago

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.

sergiocasero commented 3 years ago

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

github-actions[bot] commented 9 months ago

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.