Android video file path from media store is coming as null

后端 未结 1 1286
[愿得一人]
[愿得一人] 2021-01-27 05:40

I am trying to get the path of the video file for a video thumbnail. I\'m not sure why it is still coming as null after I modified based on some solutions here. The version of a

相关标签:
1条回答
  • 2021-01-27 06:21

    and summons a gallery of videos

    No, it does not. It allows the user to choose from any activity that supports ACTION_GET_CONTENT for a MIME type of video/*. The Uri that you get back can be from anything, not necessarily a "gallery" app, and not necessarily one that points to a file. The Uri could point to:

    • A file on external storage, one that you might be able to read directly
    • A file on removable storage, which you cannot access
    • A file on internal storage of some other app
    • The contents of a BLOB column in a database
    • Something that has to be decrypted on the fly
    • Something that does not yet exist on the device and needs to be downloaded
    • And so on

    The method to get the path of the video file

    The only values you can get back from that query(), reliably, are the OpenableColumns, for the size and "display name" of the content.

    You need to either:

    • Use a thumbnail engine that accepts a content Uri as a parameter, or

    • Use ContentResolver and openInputStream() to get an InputStream on the content, then use some thumbnail engine that accepts an InputStream as a parameter, or

    • Use ContentResolver and openInputStream() to get an InputStream on the content, then use that stream to make your own file that contains a copy of the bytes from the content, so you can use your own file with some thumbnail engine that requires a file, or

    • Do not use ACTION_GET_CONTENT, but instead render your own "chooser" UI by asking the MediaStore for all videos, as you can get thumbnails of those videos from MediaStore (see this sample app)

    0 讨论(0)
提交回复
热议问题