2

using package Flutter Sound i am able to record an audio and can play the audio by the audio URL/Uri but after playing audio what i need is to convert that audio into a file with extension of mp3 and upload it to the firebase storage. or is there some kind of a solution that i can upload a Uri and can Play the audio in future form firebase. here is my code.... For Recording

FlutterSoundRecorder recorder = new FlutterSoundRecorder();
recorder.openAudioSession();
recorder.startRecorder(codec: Codec.opusWebM,toFile: 'newRecord');

Playing Audio

 player.openAudioSession();
 player.startPlayer(fromURI: "newRecord");

Uploading File

                fileUrl= await recorder.getRecordURL(path: 'newRecord').then((value)async
                            {
                            fb.StorageReference storageRef = 
                            fb.storage().ref().child("newRecord.mp3");

                            fb.UploadTask uploadTask=storageRef.put(value);
                            fb.UploadTaskSnapshot uploadTaskSnapshot = await 
                            storageRef.put(value).future;
                            var downloadUrl = (await uploadTaskSnapshot.ref.getDownloadURL());
                            //final String url = downloadUrl as String ;
                            print(downloadUrl);


                            });

file get uploaded but its a damaged file and i cannot download and play the audio. if any one can guide me please put an answer.

  • to play audio from an url you'll find an interesting solution here : https://medium.com/flutter-community/flutter-web-audio-player-24bded45b928 – giulp Jul 29 '21 at 10:29

0 Answers0