Open creativecreatorormaybenot opened 4 years ago
I could theoretically also upload the file to external storage and play it from there, but I am interested in playing local audio files, e.g. to play it before publishing :)
This might actually be a more complicated issue caused by MediaRecorder
: https://github.com/muaz-khan/RecordRTC/issues/274
It is actually a Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=642012
The WebM files by Chrome are broken and not this plugin.
I will investigate a little bit more before closing.
Investigation update:
There appears to be a workaround to get the duration.
Now, there are two questions:
From my side, I will look into https://www.npmjs.com/package/ts-ebml and see if I can integrate it into the microphone
plugin as a different workaround.
→ the duration works already in Firefox but the replay button does not; maybe that is an issue of the example or another web issue. I might look into that at some point, but not tomorrow because tomorrow I will look at reencoding :)
The workaround looks interesting, but there are a number of reasons why a duration may be unknown (e.g. live streams) and the workaround probably shouldn't be used universally in case it has unwanted effects on some types of media. Although maybe it could be an option.
One other option I was considering was to use an existing Javascript media library that tries to transparently handle platform-specific issues. From memory, Google created such a library which also implemented DASH support, although I don't remember what it was called, my hope is that a library like that might solve a number of issues all at once.
is this still on the radar ?
Doing a quick search for the Google library I mentioned above, I found:
https://github.com/google/shaka-player
But, it looks like it's not a general solution for audio playback and doesn't solve this duration problem for us. So @creativecreatorormaybenot 's linked solution looks like the way forward.
Unfortunately it is not high on my priority list, so if anyone would like to help contribute to the project, you are more than welcome to create a pull request.
Which API doesn't behave as documented, and how does it misbehave? Name here the specific methods or fields that are not behaving as documented, and explain clearly what is happening.
Minimal reproduction project See the
duration-null-on-web
branch in this fork.To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
flutter run -d chrome
This will record a local audio file (using your microphone) and then load it into
just_audio
usingsetUrl
.Here is a video recording illustrating the issue completely: https://youtu.be/ZrLdbIjCA_g Have fun with it 😄
Error messages There is no error message.
Expected behavior
This snippet should not print
null
as the duration (line 28-29).Screenshots See the video instead :)
Desktop (please complete the following information):
Smartphone (please complete the following information): Not applicable.
Flutter SDK version
Additional context I have not experienced these problem when loading an audio file from the web, e.g.: