Android:如何知道MediaPlayer是否已暂停? [英] Android : how to know if MediaPlayer is paused?

查看:473
本文介绍了Android:如何知道MediaPlayer是否已暂停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MediaPlayer.isPlaying()不允许知道MediaPlayer是停止还是暂停.如何知道它是否已暂停且未停止?

MediaPlayer.isPlaying() does not allow to know if the MediaPlayer is stopped or paused. How to know if it is paused and not stopped?

谢谢!

推荐答案

一种方法是检查媒体播放器是否未播放(暂停),并检查其是否位于起始位置以外的位置(1 ).

One way to do this is to check if the media player it not playing (paused) and check if it is at a position other than the starting position (1).

MediaPlayer mediaPlayer = new MediaPlayer();

Boolean isPaused = !mediaPlayer.isPlaying() && mediaPlayer.getCurrentPosition() > 1;

这篇关于Android:如何知道MediaPlayer是否已暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆