Open LianVyv opened 3 days ago
what is your phone version? (API version)
I think it is Android Version 12
you should search for "software information" in Settings, it should show something like Android version
Android version 10(Q)
hi @LianVyv in this case the catch
block will run, can you check what do you have in the error? (try to get stacktrace, message,...)
Like this:
public static MediaMetadataRetriever getMediaMetadataRetriever(String source) {
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try {
if (source.startsWith("http://") || source.startsWith("https://")) {
retriever.setDataSource(source, new HashMap<>());
} else {
retriever.setDataSource(source);
}
return retriever;
} catch (Exception e) {
Log.e(TAG, "Error setting data source");
Log.e(TAG, e.printStackTrace());
Log.e(TAG, e.getMessage());
try {
retriever.release();
} catch (Exception ee) {
Log.e(TAG, "Error releasing retriever", ee);
}
return null;
}
}
@maitrungduc1410 I have came across this issue where my one Huawei phone is not working when setting the retriever.setDataSource(source). It keeps returning a null.
I have ended up fixing it by doing the following
I have tested on my other Android phones and it seems to work fine. But not sure what impact that has on other phones. I also realised if I run
Then I always get File not found.
So I have had to add a
.replace("file://", "")
Can I create a PR for this or you see any problems?