I am having trouble with ExoPlayer playing an inte...
# android
a
I am having trouble with ExoPlayer playing an internal video from the downloads folder, SecurityPermissions all around. Code in 🧵
😶 3
The exact error:
Copy code
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider uri <content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/kitty.mp4> from pid=20754, uid=10171 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
I use the
OpenDocument()
activity result listener and set the following flags on the intent:
Copy code
addFlags(FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
addFlags(FLAG_GRANT_READ_URI_PERMISSION)
When receiving a result I set the following on the
contentResolver
to receive a lasting permission:
Copy code
contentResolver.takePersistableUriPermission(uri, FLAG_GRANT_READ_URI_PERMISSION)
then I load the video uri into the exoplayer by creating a MediaItem:
Copy code
MediaItem.fromUri(videoUri)
and set it on the player
I tried the same with
getContent()
as an
ActivityResultListener
but that didn't help.. I suspect the exoplayer starting a player thread with a non-permission enabled
contentResolver
or something to that effect but I cannot put my finger on it yet. Did someone use SAF with ExoPlayer and can help me out here?