@neoskola/auto-play 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -181,12 +181,6 @@ class HybridAutoPlay: HybridAutoPlaySpec {
181
181
  carPlayTemplate,
182
182
  animated: animated
183
183
  )
184
- } else if carPlayTemplate is CPNowPlayingTemplate {
185
- // CPNowPlayingTemplate is a system singleton — do NOT push it.
186
- // It configures MPNowPlayingInfoCenter and MPRemoteCommandCenter in init,
187
- // which makes CarPlay show the NowPlaying bar automatically when audio plays.
188
- print("[AutoPlay] CPNowPlayingTemplate configured (not pushed — managed by system)")
189
- return
190
184
  } else {
191
185
  let _ = try await interfaceController.pushTemplate(
192
186
  carPlayTemplate,
@@ -49,6 +49,15 @@ class AutoPlayInterfaceController: NSObject, CPInterfaceControllerDelegate {
49
49
  _ templateToPush: CPTemplate,
50
50
  animated: Bool
51
51
  ) async throws -> Bool {
52
+ // CPNowPlayingTemplate is a singleton — check if already in the stack
53
+ if templateToPush is CPNowPlayingTemplate {
54
+ let alreadyInStack = interfaceController.templates.contains(where: { $0 is CPNowPlayingTemplate })
55
+ if alreadyInStack {
56
+ print("[AutoPlay] CPNowPlayingTemplate already in stack, skipping push")
57
+ return true
58
+ }
59
+ }
60
+
52
61
  return try await interfaceController.pushTemplate(
53
62
  templateToPush,
54
63
  animated: animated
@@ -18,6 +18,7 @@ class NowPlayingTemplate: AutoPlayTemplate {
18
18
  self.config = config
19
19
 
20
20
  template = CPNowPlayingTemplate.shared
21
+ initTemplate(template: template, id: config.id)
21
22
 
22
23
  setupNowPlayingButtons()
23
24
  updateNowPlayingInfo()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neoskola/auto-play",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",