I'm facing a strange issue when using the android.media.MediaMetadataRetriever. It fails to extract the video width from video files on Samsung phones with Android version 4.0.4 and 4.1.2. The call metaRetriever.extractMetadata() seems to return either null or an empty string, as users of my app are reporting the VideoSetupException with error code ASVF_3.
It works on the Google emulators with said Android versions and all other Android versions and devices.
Any idea what might be causing this? It seems to me that there is a bug in the Android version distributed by Samsung.
Thanks a lot.
M.
private void setVideoViewDimensionToMatchVideoMetadata(VideoView videoView, Uri uri) {
String metadataVideoWidth;
String metadataVideoHeight;
try {
final MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever();
metaRetriever.setDataSource(getActivity(), uri);
metadataVideoWidth = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
metadataVideoHeight = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
metaRetriever.release();
} catch (NullPointerException | IllegalArgumentException ex) {
throw new VideoSetupException(getActivity().getString(R.string.ASVF_2)
+ StringUtils.SPACE + ex.getLocalizedMessage(), ex);
}
if (StringUtils.isEmpty(metadataVideoWidth)) {
throw new VideoSetupException(getActivity().getString(R.string.ASVF_3));
}