audio_waveforms
audio_waveforms copied to clipboard
Advice: Compatible encoding format for iOS and Android and disabling animation
Hi,
Firstly, great impressive plugin which I'm using for a chat app - but having a couple issues was hoping someone could help / advise
-
Is there a way to disable the animation? I have a list view that refreshes and sometimes the components rebuild, which triggers the animation. I've looked into several ways to try cache the widget, through keys and various other means, but ultimately, the animation really draws attention to the refresh.
-
I commented on a closed issue, that I couldn't get the example code to work for iOS. I had to change the encoder format. I tried on iPhone 8 and 13 devices (iOS 15). I found the format that seems to be prmilary ok for iOS is
kAudioFormatMPEG4AAC_HE_V2
.
However, whilst the iOS file and it's waveform generates / display fine on Android when sent across the wire, playing it back it is silent. Android to iOS files play back fine. Is there a certain combination you know should work between the two different platforms or is some additional conversion required? I noticed missing / incorrect file extensions also can easily break the recording.
I was wondering should the kAudioFormatMPEG4AAC
format as used in your example code work fine on iOS? I find it odd that two devices would exhibit same, non-working behaviour in your example code implementation and also my own app without it being a known issue.
Your help is much appreciated
Hey @codecoded,
-
If you are talking about waveforms from a file then you can just pass
Duration.zero
and it won't animate the waves. -
I must have missed your comment so thanks for filing a new issue. Now, we have set the default value of encoder
kAudioFormatMPEG4AAC
because it's the default for ios, so it makes sense to just use that or you can try changing the default values ofsampleRate
andbitRate
. We are going to change those default values to 44100 and 48000 in the next release so you can also try those values.
I wasn't aware about the ios -> android audio file doesn't playback so I will check that
hey @ujas-m-simformsolutions
Thanks for getting back.
-
Duration.zero
was my first thought too - but it actually doesn't display the waves properly - more a flat line - they render fine if you play the controller though. This happens with the example project for me as well as my own app. -
Regarding
kAudioFormatMPEG4AAC
- I'm saying this doesn't work for me when I use this, and this is tested on 2 real iPhones and iPhone 13 Pro simulator. I have to to change tokAudioFormatMPEG4AAC_HE_V2
which works fine on iPhone, but I think this is what is casuing me issues with Android.
The behaviour when using kAudioFormatMPEG4AAC
shows the recording waveform scrolling but it's flat / non-responsive. At the end, there's a file but it's always only 28 bytes long. I've tried different file paths / extensions etc when using this encoder but still no success :-(
Hope that clears my issues up a bit better!
Update: I've been playing with the AudioRecorder.swift
file from your codebase and made some progress my taking an example of getting a document directory for it and using that
...
let audioFilename = getDocumentsDirectory().appendingPathComponent("recording.m4a")
audioRecorder = try AVAudioRecorder(url: audioFilename, settings: settings)
...
func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return paths[0]
}
Also - the example bitrate of 64000 does not work - but those values you provide did.
However, whilst the waveform looks ok during recording, when playing back, the first half or so is represented as a flat line
So there's a couple of things I'm trying to establish now:
- What exactly is the correct path / file format that will work
- Why is
kAudioFormatMPEG4AAC
files displaying incorrectly after recording.
Any further advice would be appreciated
Update 2: The file plays fine on Android but the issue with the waveform not displaying properly still exists - it's really my main last issue blocking me :-( Thanks
#103 this PR will fix waveforms not expanding when you provide zero
duration and from your last update do audio files from ios to android play now if you use 44100 sample rate and 48000 bit rate?
Hey
That's great new on the animation - look forward to it.
The new values certainly help - but when I tried your PR two things remain
-
The recording waveform doesn't update properly but at least the sound is recorded. However, if I use the example files code posted above then the recording waveform does work properly (but it's hardcoded file path )
-
The
kAudioFormatMPEG4AAC
recorded on iOS waveform in the player controller doesn't display properly on iOS or Android but does play ok. It has a long leading flat line gap then displays the correct waveform in the last 1/3. Oddly the file recorded on Android displays fine on iOS and Android!
Let me know if you need more info
2. 44100
Thank you for the PR. Please update the documentation accordingly
@codecoded and @loic-hamdi we have released 1.0.0
to pub.dev. In which, we have made bitRate nullable. So that platform can decide whatever bitRate is suitable. Mostly the bitRate parameter was interfering with other audio formats. So if you want to set bitRate then do make sure its right value.
Also we have updated how waveforms gets extracted so it should be more accurate now.
I'm going to close this issue for now. If you have any other issue feel free to create new issue.