With the Google Photos app, I am trying to pick a video, that is not cached on the device.
I am using the ACTION_GET_CONTENT intent, to launch the options dialog, and from there I choose the Google Photos app.
While selecting local videos, it returns an Uri in this form.
content://media/external/video/media/6708
And from that, I query the content provider to retrieve the actual file location, and proceed from there. The file location looks like this.
/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20131102-WA0000.mp4
Now, when I choose an online video, i.e: a video not available on my device yet, and which needs to be downloaded to be used, the returned Uri looks like this:
content://com.google.android.apps.photos.content/1/https://lh6.googleusercontent.com/_RD-QTO_SK5jlaPldTe2n5GANqMc3h-ukcbNoFlF1NLy=s0-d
Now, with this, there is no documented ContentProvider that would help me to get the actual link to this video. Even if I do a query, it returns nothing apart from a DISPLAY_NAME and SIZE columns.
DISPLAY_NAME contains video.mpeg (Same display name for different videos)
SIZE probably tells me the size of the actual file.
I checked various posts, and thought that I would have to get an InputStream for the video through the content provider, save the file, and work with the file. Picking an image file however works fine, but with video it doesn't.
So, to copy the stream to a file, I have this code.
InputStream inputStream = context.getContentResolver().openInputStream(Uri.parse(path));
And finally write to a temporary file. The file gets created, but that doesn't seem to be correctly formatted. VLC plays the file, but shows only the first frame all throughout.
If I take the URL from the last part of the URI given above, and try to view it on a browser, it downloads a GIF file. I am guessing that's the problem. But I don't know how to get the mpeg format of the video.
Anyone has experienced the same?