HOWTO接收媒体的体积变化通知?体积、通知、媒体、HOWTO

2023-09-06 03:29:09 作者:男友难有

是否可以注册一个BroadcastReceiver或东西来获得媒体播放器的音量变化的通知?

Is it possible to register a BroadcastReceiver or something to get notifications of media player volume changes?

感谢

推荐答案

立即值,你可以得到,如果你使用AudioManager

Immediate value you can get if you use AudioManager

AudioManager mAudioManager = Context.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.getStreamVolume(STREAM_MUSIC);

的唯一功能,让您有机会注册广播接收器

The only function that gives you opportunity to register broadcast receiver is

mAudioManager.registerMediaButtonEventReceiver(audioBroadcastReceiver);

在这里audioBroadcastReceiver延伸的BroadcastReceiver,必须在应用程序清单中声明。

where audioBroadcastReceiver extends BroadcastReceiver and must be declared in the application manifest.

不知道这正是你所期待的。

Not sure if this is exactly what you were looking for.