Hello community.
i used a secure nginx url like this:
domain/video.mp4?md5=4d2swh16c4hOPXiGKhFIpQ&expires=1587514975
but exoplayer is not playing the url after i add the security key and the following error appear on my android studio logs.
com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException: com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException: uri has query and/or fragment, which are not supported. Did you call Uri.parse() on a string containing '?' or '#'? Use Uri.fromFile(new File(path)) to avoid this. path=,query=md5=2ISlTKfGz_hGYkVoNkxOIw&expires=1587515112,fragment=null
Thank you
That error indicates ExoPlayer is trying to handle your URL as a local file path (it's thrown from inside a method called openLocalFile).
This is likely because you didn't include a scheme e.g. https://. When Uri.parse() is passed a 'naked' string with no scheme it assumes it's a path to a local file and converts it into a file:// URI (for which fragments & queries are not supported).
actually i am including http:// etc. the url on here is not with http as it's just an example
Something else is going wrong then. If you're using DefaultDataSource then a URI with http scheme should be handled by a HttpDataSource not FileDataSource. If you're directly passing an HTTP URI to FileDataSource then that wouldn't work, and this might be the failure you'd see.
What happens if you try and play the URL in the demo app?
A full adb bugreport might help us debug further. Otherwise if it's specific to your application and doesn't reproduce in the demo app then please provide a minimal reproducible example that demonstrates the problem in a way that we build locally. This could be an Android Studio project on GitHub, or zipped up and sent to dev.[email protected] (with subject "Issue #1234").
If you're unable to share bug reports publicly, please send them to dev.[email protected] using a subject in the format "Issue #1234", where "#1234" should be replaced with your issue number. Please also update this issue to indicate you鈥檝e done this.
I have fixed the problem and it was my mistake to be honest
the problem was that the API that i use to fetch movie is providing me with subtitle that is as well protected with this md5 hash security key
so by disabling the loading of subtitle the app stooped crashing and video loaded correctly.
i was not wrong posting my problem here as by pointing that the error is about file open not httpdatasource the suspection of subtitle jumped to my mind.
Thank you for your help
Most helpful comment
That error indicates ExoPlayer is trying to handle your URL as a local file path (it's thrown from inside a method called
openLocalFile).This is likely because you didn't include a scheme e.g.
https://. When Uri.parse() is passed a 'naked' string with no scheme it assumes it's a path to a local file and converts it into afile://URI (for which fragments & queries are not supported).