improve isMediaFile() guess
This commit is contained in:
1 parent
a98eb36a1c
commit
446912c225
1 file changed
+10
-15
@@ -210,6 +210,11 @@ public class MediaMetadataExtractor extends HashMap<String, ArrayList<String>> {
|
||||
// 148 goes here, Winamp 5.6 would have 148 -> 191 these ¯\_(ツ)_/¯
|
||||
};
|
||||
|
||||
/**
|
||||
* True if we consider the file to be a good media item
|
||||
*/
|
||||
private boolean mIsMediaFile = false;
|
||||
|
||||
/**
|
||||
* Constructor for MediaMetadataExtractor
|
||||
*
|
||||
@@ -237,21 +242,7 @@ public class MediaMetadataExtractor extends HashMap<String, ArrayList<String>> {
|
||||
* @return true if file is considered to be media data
|
||||
*/
|
||||
public boolean isMediaFile() {
|
||||
// We consider the file to be OK if it has some tags
|
||||
if (containsKey(TITLE) || containsKey(ALBUM) || containsKey(ARTIST))
|
||||
return true;
|
||||
|
||||
// Otherwise, check if the bitrate makes sense for an audio file.
|
||||
// That is: more than 60kbit/s but less than 1600kbit/s
|
||||
String rawBitrate = getFirst(BITRATE);
|
||||
if (rawBitrate != null) {
|
||||
int bitrate = Integer.parseInt(rawBitrate);
|
||||
if (bitrate > 60000 && bitrate < 1600000)
|
||||
return true;
|
||||
}
|
||||
|
||||
// so this does not look like audio:
|
||||
return false;
|
||||
return mIsMediaFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,6 +298,10 @@ public class MediaMetadataExtractor extends HashMap<String, ArrayList<String>> {
|
||||
convertNumericGenre();
|
||||
}
|
||||
|
||||
// We consider this a media file if it has some common tags OR
|
||||
// if bastp was able to parse it (which is stricter than Androids own parser)
|
||||
mIsMediaFile = (containsKey(TITLE) || containsKey(ALBUM) || containsKey(ARTIST) || !bastpType.equals(""));
|
||||
|
||||
mediaTags.release();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user