Closed NielsH12 closed 1 year ago
I'm a bit confused by your bug report since you talk about HTTP status codes and yet your example uses the file://
scheme.
Like I saId, it's outside my area of expertise. But if I look at the developer tools in Chrome under networking, I see a Status 200.
file://
URIs are not supported on web due to the security model.
What does this mean? AudioPlayer can't play mp3 files on Flutter Web? Did you try the example I provided?
Is your intention to deploy this web app "on the web"? I'm trying to understand what use case you might have where you would need to use a file://
URI -- something that websites "on the web" would block.
I'd like to host a webapp where clients can play their own mp3 files. As such, the files are only present client side. Am I going about this all wrong?
I can't provide advice on that, but you might try searching past questions on StackOverflow (not necessarily flutter-specific) or asking a new question, and once you have the advice on what features will help you build your app, you can then make a feature request here regarding what you need.
People have tried to do similar things in the past with just_audio so if you search the past issues on this page you might also find approaches that may currently work for some use cases.
Perhaps the author is trying to load an mp3 file via input upload so what they get in return is a temp file:// path or a blob
@netgfx Yup, that is exactly what I was trying to do.
Well you could try saving it locally https://stackoverflow.com/questions/67508623/how-to-save-streamedresponse-of-audio-to-file-in-flutter and then reading it from this library or use audio players https://stackoverflow.com/questions/65607152/how-can-i-play-local-mp3-on-flutter-web where you can provide the path of the file (although not sure it will play correctly)
Just to know that web can't do that either, its a browser security issue not a flutter one @NielsH12
As I have said above, I don't believe you can use file://
URIs due to the web security model, but people have done this sort of thing so I recommend searching past issues. As for whether this is a bug, I don't think it's a bug since your code is trying to do something that is not supported by the web security model.
or use audio players https://stackoverflow.com/questions/65607152/how-can-i-play-local-mp3-on-flutter-web where you can provide the path of the file (although not sure it will play correctly)
No it won't play correctly because as mentioned, you can't use file://
URIs on the web due to the security model.
I will close this as it is not a bug.
However, I recommend searching past issues. What you need to do is use a file picker that doesn't give you the file path (which you can't use) but instead gives you a stream of bytes or an array of bytes. Once you have that, you can render that with your own StreamAudioSource
. Searching past issues or StackOverflow questions about this may be helpful.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.
Which API doesn't behave as documented, and how does it misbehave?
AudioPlayer.play()
sometimes resets the position on the AudioSource. EvenAudioPlayer.seek()
doesn't work. It is a bit inconsistent in it's behavior, and it's a bit outside my area of expertise. But as far as I can tell. It depends on whether the HTTP response from the server is 200 or 206. I have found it to fail more consistenly on larger files.Minimal reproduction project https://github.com/NielsH12/just_audio
You might also be able to reproduce it with the existing sample file if you change main.dart to use the included mp3 file:
await _player.setAudioSource(AudioSource.uri(Uri.file("audio/nature.mp3")));
To Reproduce (i.e. user steps, not code)
Expected behavior I expected the playback to resume from where I paused.
Desktop (please complete the following information):
Flutter SDK version