1
0
mirror of https://github.com/danog/termux-api.git synced 2024-11-30 04:19:20 +01:00

MediaPlayerAPI: remove extension pattern check

There are way more possibilities and extension doesn't guarantee
anything about the file.
This commit is contained in:
Tom Yan 2018-04-04 17:55:21 +08:00 committed by Fredrik Fornwall
parent 35ba761e3a
commit 1be62a5c91

View File

@ -14,7 +14,6 @@ import com.termux.api.util.TermuxApiLogger;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.regex.Pattern;
/**
* API that enables playback of standard audio formats such as:
@ -171,17 +170,6 @@ public class MediaPlayerAPI {
});
}
/**
* Checks to see if the specified file exists and is a supported media type
* @param file
* @return
*/
protected static boolean isValidMediaFile(File file) {
final String MEDIA_PATTERN = ".3gp|.flac|.mkv|.mp3|.ogg|.wav$";
Pattern pattern = Pattern.compile(MEDIA_PATTERN);
return pattern.matcher(file.getName()).find();
}
/**
* -----
* Media Command Handlers
@ -210,9 +198,6 @@ public class MediaPlayerAPI {
File mediaFile = new File(intent.getStringExtra("file"));
if (!isValidMediaFile(mediaFile)) {
result.error = "Invalid file: " + mediaFile.getName();
} else {
if (player.isPlaying()) {
player.stop();
player.reset();
@ -224,7 +209,6 @@ public class MediaPlayerAPI {
} catch (IOException e) {
result.error = e.getMessage();
}
}
return result;
}
};