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

MediaPlayerAPI: check whether playback has been successfully started

This commit is contained in:
Tom Yan 2018-04-04 19:33:31 +08:00 committed by Fredrik Fornwall
parent 7bdd53008a
commit 299d55789b

View File

@ -205,7 +205,11 @@ public class MediaPlayerAPI {
try {
player.setDataSource(context, Uri.fromFile(mediaFile));
player.prepareAsync();
if (player.isPlaying()) {
result.message = "Now Playing: " + mediaFile.getName();
} else {
result.error = "Failed to play: " + mediaFile.getName();
}
} catch (IOException e) {
result.error = e.getMessage();
}