mediaMetaDataRetriver.setDataSource(string path) not working in Android Studio

218 Views Asked by At
m_mediaMetadataRetriever = MediaMetadataRetriever()
m_mediaMetadataRetriever.setDataSource(p_videoPath)
m_bitmap = m_mediaMetadataRetriever.frameAtTime

I am trying to get the frame from a video that I recorded using MediaStore.Action_Video_Capture. The video is stored at a location /storage/emulated/0/DCIM/Camera/PXL_1345657.mp4

But after running the above code the bitmap is coming null and setDataSource is showing an IllegalArgumentException.

1

There are 1 best solutions below

3
S-Sh On

There is another overload method that only worked for me: setDataSource(Context, Uri). You should obtain Uri of the file (with proper permissions) and pass it to the method with according context.