1
0
mirror of https://github.com/danog/termux-api.git synced 2024-11-26 20:04:42 +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();
result.message = "Now Playing: " + mediaFile.getName();
if (player.isPlaying()) {
result.message = "Now Playing: " + mediaFile.getName();
} else {
result.error = "Failed to play: " + mediaFile.getName();
}
} catch (IOException e) {
result.error = e.getMessage();
}