axiom-now-playing-carplay by charleswiltgen/axiom
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-now-playing-carplay所需时间:15-20 分钟(如果 MPNowPlayingInfoCenter 已正常工作)
CarPlay 使用与锁屏界面和控制中心相同的 MPNowPlayingInfoCenter 和 MPRemoteCommandCenter。 如果你的“正在播放”集成在 iOS 上有效,那么它在 CarPlay 上会自动生效,无需任何额外代码。
| iOS 组件 | CarPlay 显示内容 |
|---|---|
MPNowPlayingInfoCenter.nowPlayingInfo | CPNowPlayingTemplate 元数据(标题、艺术家、封面图) |
MPRemoteCommandCenter 处理器 | CPNowPlayingTemplate 按钮响应 |
来自 nowPlayingInfo 的封面图 | CarPlay UI 中的专辑封面 |
无需 CarPlay 特定的元数据。你现有的代码即可工作。
对于超出标准播放/暂停/跳过之外的自定义播放控制:
import CarPlay
@MainActor
class SceneDelegate: UIResponder, UIWindowSceneDelegate, CPTemplateApplicationSceneDelegate {
func templateApplicationScene(
_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController
) {
// ✅ 在连接时配置 CPNowPlayingTemplate(而不是在推送时)
let nowPlayingTemplate = CPNowPlayingTemplate.shared
// 启用专辑/艺术家浏览(显示一个按钮,可在你的应用中导航到专辑/艺术家视图)
nowPlayingTemplate.isAlbumArtistButtonEnabled = true
// 启用“接下来播放”队列(显示一个按钮,展示即将播放的曲目)
nowPlayingTemplate.isUpNextButtonEnabled = true
// 添加自定义按钮(iOS 14+)
setupCustomButtons(for: nowPlayingTemplate)
}
private func setupCustomButtons(for template: CPNowPlayingTemplate) {
var buttons: [CPNowPlayingButton] = []
// 播放速率按钮
let rateButton = CPNowPlayingPlaybackRateButton { [weak self] button in
self?.cyclePlaybackRate()
}
buttons.append(rateButton)
// 随机播放按钮
let shuffleButton = CPNowPlayingShuffleButton { [weak self] button in
self?.toggleShuffle()
}
buttons.append(shuffleButton)
// 重复播放按钮
let repeatButton = CPNowPlayingRepeatButton { [weak self] button in
self?.cycleRepeatMode()
}
buttons.append(repeatButton)
// 使用自定义按钮更新模板
template.updateNowPlayingButtons(buttons)
}
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
CarPlay 需要在你的 Xcode 项目中设置一个权限:
Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
Entitlements 文件:
<key>com.apple.developer.carplay-audio</key>
<true/>
如果没有此权限,CarPlay 将完全不会显示你的应用。
| 问题 | 原因 | 解决方法 | 时间 |
|---|---|---|---|
| CarPlay 不显示应用 | 缺少权限 | 添加 com.apple.developer.carplay-audio | 5 分钟 |
| CarPlay 中“正在播放”为空 | MPNowPlayingInfoCenter 未设置 | 与锁屏界面相同的修复方法(模式 1) | 10 分钟 |
| 自定义按钮不出现 | 在推送后配置 | 在 templateApplicationScene(_:didConnect:) 中配置 | 5 分钟 |
| 按钮在设备上有效,在 CarPlay 模拟器中无效 | 调试器干扰 | 在不附加调试器的情况下测试 | 1 分钟 |
| 专辑封面缺失 | 与 iOS 问题相同 | 修复 MPMediaItemArtwork(模式 3) | 15 分钟 |
模拟器(Xcode 12+):
真实车辆: 需要 Apple 批准权限(对于具有 UIBackgroundModes audio 的应用是自动的;无需手动申请)。
技能:axiom-now-playing, axiom-now-playing-musickit
每周安装量
91
代码仓库
GitHub 星标数
606
首次出现
2026年1月21日
安全审计
安装于
opencode76
claude-code72
codex71
gemini-cli69
cursor69
github-copilot66
Time cost : 15-20 minutes (if MPNowPlayingInfoCenter already working)
CarPlay uses the SAME MPNowPlayingInfoCenter and MPRemoteCommandCenter as Lock Screen and Control Center. If your Now Playing integration works on iOS, it automatically works in CarPlay with zero additional code.
| iOS Component | CarPlay Display |
|---|---|
MPNowPlayingInfoCenter.nowPlayingInfo | CPNowPlayingTemplate metadata (title, artist, artwork) |
MPRemoteCommandCenter handlers | CPNowPlayingTemplate button responses |
Artwork from nowPlayingInfo | Album art in CarPlay UI |
No CarPlay-specific metadata needed. Your existing code works.
For custom playback controls beyond standard play/pause/skip:
import CarPlay
@MainActor
class SceneDelegate: UIResponder, UIWindowSceneDelegate, CPTemplateApplicationSceneDelegate {
func templateApplicationScene(
_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController
) {
// ✅ Configure CPNowPlayingTemplate at connection time (not when pushed)
let nowPlayingTemplate = CPNowPlayingTemplate.shared
// Enable Album/Artist browsing (shows button that navigates to album/artist view in your app)
nowPlayingTemplate.isAlbumArtistButtonEnabled = true
// Enable Up Next queue (shows button that displays upcoming tracks)
nowPlayingTemplate.isUpNextButtonEnabled = true
// Add custom buttons (iOS 14+)
setupCustomButtons(for: nowPlayingTemplate)
}
private func setupCustomButtons(for template: CPNowPlayingTemplate) {
var buttons: [CPNowPlayingButton] = []
// Playback rate button
let rateButton = CPNowPlayingPlaybackRateButton { [weak self] button in
self?.cyclePlaybackRate()
}
buttons.append(rateButton)
// Shuffle button
let shuffleButton = CPNowPlayingShuffleButton { [weak self] button in
self?.toggleShuffle()
}
buttons.append(shuffleButton)
// Repeat button
let repeatButton = CPNowPlayingRepeatButton { [weak self] button in
self?.cycleRepeatMode()
}
buttons.append(repeatButton)
// Update template with custom buttons
template.updateNowPlayingButtons(buttons)
}
}
CarPlay requires an entitlement in your Xcode project:
Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
Entitlements file:
<key>com.apple.developer.carplay-audio</key>
<true/>
Without the entitlement, CarPlay won't show your app at all.
| Issue | Cause | Fix | Time |
|---|---|---|---|
| CarPlay doesn't show app | Missing entitlement | Add com.apple.developer.carplay-audio | 5 min |
| Now Playing blank in CarPlay | MPNowPlayingInfoCenter not set | Same fix as Lock Screen (Pattern 1) | 10 min |
| Custom buttons don't appear | Configured after push | Configure at templateApplicationScene(_:didConnect:) | 5 min |
| Buttons work on device, not CarPlay simulator | Debugger interference | Test without debugger attached | 1 min |
| Album art missing | Same as iOS issue | Fix MPMediaItemArtwork (Pattern 3) |
Simulator (Xcode 12+):
Real Vehicle: Requires entitlement approval from Apple (automatic for apps with UIBackgroundModes audio; no manual request needed).
Skills : axiom-now-playing, axiom-now-playing-musickit
Weekly Installs
91
Repository
GitHub Stars
606
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode76
claude-code72
codex71
gemini-cli69
cursor69
github-copilot66
Remotion 演练视频制作指南:使用 Stitch 与 Remotion 创建专业应用演示视频
16,300 周安装
SoulTrace 人格评估 API - 基于五色心理模型的贝叶斯自适应测试
20,400 周安装
Git Commit 规范指南:使用 Conventional Commits 标准化提交信息
21,000 周安装
Playwright 最佳实践指南 - 端到端测试、组件测试、API测试全面教程
21,600 周安装
Expo原生UI开发指南:构建iOS/Android原生界面与动画效果
25,200 周安装
Overdrive:浏览器极限性能优化,打造非凡用户体验的Web界面增强技能
25,900 周安装
| 15 min |