问题标签 [avsystemcontroller]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ios - 如何根据 UIslider 值设置系统音量?IOS 斯威夫特 3.0
我正在使用以下代码获取系统音量,但是如何在更改 UISlider 值时设置系统音量?
ios - AVSystemController_SystemVolumeDidChangeNotification triggers when device locked
Using iOS 12, I am observing AVSystemController_SystemVolumeDidChangeNotification
to detect volume presses to capture images:
However, I've noticed that the notification also fires, at least on an iPhone XS and XS Max, when the lock button (on the right side of the device) is pressed.
Tried searching around and haven't seen anyone mentioning this issue or much discussion of this notification. Other similar attempts to listen to the volume buttons presses use AVAudionSessions / KVO, but I found that whenever I used that the observer did not get called when the volume was already at max/min. This AVSystemController_SystemVolumeDidChangeNotification
seems to work just fine, except for this strange lock button issue. Don't see how, from the name of the notification, why it would respond to the lock button being pressed.
When the lock button is pressed I get the following messages in the console:
[avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker) // this appears four times
+[CATransaction synchronize] called within transaction // this appears twice
These logs do not appear when the volume button is pressed.
Note also I don't plan to submit the App Store, so I am not concerned about whether Apple rejects this app on the basis of using this possibly private notification.
If instead of AVSystemController_SystemVolumeDidChangeNotification
I create an AVAudioSession
and observe outputVolume
like so:
… then it isn't hit when the device locks, but I'm still seeing the "AVAudioSessionPortImpl.mm unknown selected data source for Port Speaker" console errors. But then when the volume is muted it doesn't receive presses anymore. I guess what I'd need to do is manually change the volume so it doesn't hit the min or max?
Thank you
ios - AVSystemController_SystemVolumeDidChangeNotification 第一次没有给回调
我想检查两个音量按钮是否工作正常。所以我设置观察者AVSystemController_SystemVolumeDidChangeNotification
来检查。
给定的是volumeCallback
方法:
现在的问题是,我没有在volumeCallback
第一次安装应用程序时收到回调。奇怪的是,这个方法是在应用程序在后台时调用的,而不是在前台调用的。
我正在使用 iPhone 5s (iOS 10.3.3)。
我不明白这段代码有什么问题。任何帮助将不胜感激。