更新时间:2023-02-27 07:39:06
与此处的Android API一致: AudioManager 应该是您想要的
In concordance with the Android API here: AudioManager should be what you are looking for
您可以创建一个 AudioManager
,然后调用 isMusicActive
来检索布尔值(如果正在播放).
You can create an AudioManager
and then call the isMusicActive
to retrieve a boolean if it is playing.
然后,您可以使用 MediaPlayer API并调用 getTrackInfo
方法,该方法返回与轨道相关的信息的 Array
.
You can then use the MediaPlayer API and call the getTrackInfo
method which returns an Array
of track-related information.
此外, MediaPlayer
有一个 isPlaying
方法,在这种情况下,它确实使AudioManager变得毫无用处.
Also, MediaPlayer
has an isPlaying
method which really makes AudioManager rather useless in this scenario.
[更新]
供以后观看此问题的读者使用;创建 MediaPlayer
对象并调用 getTrackInfo
方法时;它返回一个数组 TrackInfo []
; TrackInfo []
的API及其方法也可以找到
For future viewers of this question; when you create a MediaPlayer
object and call the getTrackInfo
method; it returns an array TrackInfo[]
; the API for TrackInfo[]
and it's methods can also be found here.