Xamarin Android: Detect if audio is currently playing on device

扶醉桌前 提交于 2020-05-30 06:43:17

问题


At app launch, is it possible to detect if the device's audio player or another app is currently playing music?


回答1:


You can use the AudioManager to achieve this with it's IsMusicActive property:

AudioManager manager = (AudioManager)Android.App.Application.Context.GetSystemService (Android.Content.Context.AudioService);
var audioDetails = "Audio is " + (manager.IsMusicActive ? "on" : "off");


来源:https://stackoverflow.com/questions/32833722/xamarin-android-detect-if-audio-is-currently-playing-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!