New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to play .m3u8 file on Android #86
Comments
Here's a more detailed error log:
|
Hi @lain-ke , as you suspected, I currently use the extension to determine the file type which would cause the problem. ExoPlayer currently doesn't have any built-in mechanism to detect the stream type, and there is an open issue discussing adding this feature: google/ExoPlayer#3165 The ExoPlayer example app also uses the extension to detect the file type, but it at least points at what a solution might look like, which is to "sniff" the first few bytes of content to determine the type. If there is an example to base this solution on, that will be helpful. Otherwise, in the meantime you will need to depend on the extension. If you have no control over the server, there is a workaround which is to create a local http server using Dart libraries and serve the file at a localhost URL with the correct extension that returns a 301 that points to the remote server. The other alternative is to provide a low-level API similar to ExoPlayer where you have to choose the media source type before you pass in the URL, but I would rather not have the API go in that direction. Automatic detection of the stream type would be preferred. |
My URL basically contains the path (not ending in the extension) and then some params apply (?token=sñldhcioygosgduyasdv & more), so if as my last param I add &extension=.m3u8, the server wouldn't even read it but ExoPlayer would recognize it and play it, right? |
Okay, I've tried it and it doesn't work, I don't know if it's because it's a param or because my server redirects to the file. Does ExoPlayer support redirects? |
Your idea of adding the extension in the query string is quite clever and it's only unfortunate that the code only considers the path part of the URL. It got me thinking that maybe a fragment could be used for this purpose as a sort of workaround, but even in this case, I would need to add some code to recognise the fragment. ExoPlayer does support redirects, which is why my previous suggestion will probably work, but maybe it'll be better if I just add some code to recognise the fragment as a temporary hack. So for example, https://somewhere.com/somestream?whatever#.m3u8 . I believe fragments are not sent in http requests, so this should be safer. |
What I've done is make the server send the url in JSON format, among with other data. I mean, the JSON output returns (for example)
or
So we already know the extension before passing it to ExoPlayer. If there isn't any way, I'll wait for you to implement your above solution. |
It's possible to do that with ExoPlayer (by choosing the media source class) but you don't have access to that at the Dart level, you only have access to the I'll try to implement the temporary hack for you. |
Thanks!! |
I've committed the work around to git master. Would you be able to test it before I include it in the next release? |
Sure! |
You can temporarily set your project to use the git master version of the plugin by changing your pubspec to: audio_service:
git:
url: https://github.com/ryanheise/audio_service.git |
Hey thanks a lot for the fix! |
Awesome, thanks for testing. |
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. |
Describe the bug
I am trying to play a .m3u8 playlist file, in iOS works but on Android, it shows an exception.
Minimal reproduction project
Example project
To Reproduce
Steps to reproduce the behavior:
Error messages
Expected behavior
The file should play like it does on iOS.
Screenshots
Not applicable.
Smartphone (please complete the following information):
Flutter SDK version
Additional context
The .m3u8 is formed by various .ts files.
Plus, the URL does not end in .m3u8, if that causes any problem.
I am also using the audio_service plugin.
The text was updated successfully, but these errors were encountered: