屏幕锁定后,MediaPlayer无法播放声音

时间:2016-06-03 17:50:15

标签: android audio android-mediaplayer alarmmanager android-6.0-marshmallow

我正在使用 [UIViewController topLayoutGuide]: guide not available before the view controller's view is loaded 2016-06-03 10:48:06.310 BlinkPDF[304:34590] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs' 在给定时间播放声音(AlarmManager)。

不幸的是,当手机被锁定时,MediaPlayer方法似乎无效。

我在Marshmallow上开发,所以我已经通过使用play()和使用CPU唤醒锁(部分唤醒锁)解决了Doze问题。奇怪的是,当警报触发时,活动会通过锁屏启动(它应该做什么),但setAlarmClock()的{​​{1}}方法无法播放。 当我旋转屏幕时,音乐开始播放。

我该如何解决这个问题,所以当手机启动时,音乐会开始播放,而手机会被锁定?

1 个答案:

答案 0 :(得分:0)

由于Dose Mode。旋转屏幕时,禁用剂量模式。尝试在白名单中添加您的应用