gpt4 book ai didi

macos - 如何在 macOS 上检测远程音频按钮?

转载 作者:行者123 更新时间:2023-12-03 16:19:14 24 4
gpt4 key购买 nike

文章中Handling External Player Events Notifications苹果说你需要这样做:

• Use the shared MPRemoteCommandCenter object to register handlers for the events you wish to handle and to disable the events you are not interested in receiving.

• Begin playing audio. Your app must be the Now Playing app. An app does not receive remote control events until it begins playing audio. Test that your app is properly receiving and handling remote control events with Control Center, which you access by swiping up from the bottom edge of your screen. These controls send remote control events to the app that is currently or was most recently playing audio. You can also access the playback controls from the lock screen of the device.

第二部分只能在 iOS 上应用并且可以在 iOS 上运行。但是,不知道如何在 macOS 上处理这个问题。我假设需要设置的一件事是设置MPNowPlayingInfoCenter。但在 macOS 上的控制中心中无法检查,我猜唯一的方法是检查 TouchBar 音频控件,但在那里似乎没有效果。所以可能需要在 iOS 上设置类似 AVAudioSession 的东西,但我在 macOS 上找不到类似的东西。而且文档几乎不存在。

请注意,我在文本转语音应用程序中使用此功能,因此我无法使用 AVPlayer 等某些 API。

最佳答案

我找到了答案 - 是的,设置 MPNowPlayingInfoCenter 就足够了,关键部分是设置 playbackState

关于macos - 如何在 macOS 上检测远程音频按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54842139/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com