ios - CarPlay CPNowPlayingTemplate 播放器按钮不起作用
问题描述
但是我实现了正确的 MPRemoteCommandCenter 功能,播放按钮在 carplay 应用程序中根本没有响应。
(使用 MPPlayableContentManager 在 iOS 14 之前的 CarPlay 中可以正常工作)
没有调用 MPRemoteCommandCenter 回调。
可能是什么原因?
我设置远程指挥中心的代码:
func setupRemoteCommandCenterTargets() {
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.playCommand.isEnabled = true
commandCenter.playCommand.addTarget {event in
//myPlayer.play()
return .success
}
commandCenter.pauseCommand.isEnabled = true
commandCenter.pauseCommand.addTarget {event in
//myPlayer.pause()
return .success
}
commandCenter.nextTrackCommand.isEnabled = true
commandCenter.nextTrackCommand.addTarget {event in
//myPlayer.next()
return .success
}
commandCenter.previousTrackCommand.isEnabled = true
commandCenter.previousTrackCommand.addTarget {event in
//myPlayer.prev()
return .success
}
}
解决方案
推荐阅读
- python - Python中的字符串结尾()
- java - @ManyToMany 无法将反向行添加到 JoinTable 自引用表。org.hibernate.exception.ConstraintViolationException:无法执行语句
- postgresql - WSL2 Ubuntu 无法 ping 本地 IP
- windows - 将 MongoDB 与 Docker 卷一起使用时,数据不会保留在数据库中吗?
- node.js - nodejs会话变量未定义
- json - 如何使用 Collection 对象在 Groovy 中获得所需的 Collection
- c++ - C++ 结构:强制初始化成员?
- r - 从R中的数据框行中删除部分字符串
- java - 带有控制线程的奇偶打印数字线程
- c++11 - C++中的模板化参数推导