@neoskola/auto-play 0.3.2 → 0.3.4

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.
@@ -60,7 +60,6 @@ class NowPlayingTemplate: AutoPlayTemplate {
60
60
 
61
61
  @MainActor
62
62
  func playAudio(url: String, startFrom: Double) -> Bool {
63
- // Clean up any existing player
64
63
  cleanupPlayer()
65
64
  completionFired = false
66
65
  lastReportedSecond = Int(startFrom)
@@ -71,17 +70,15 @@ class NowPlayingTemplate: AutoPlayTemplate {
71
70
  return false
72
71
  }
73
72
 
74
- // Ensure AVAudioSession is active
75
73
  NowPlayingSessionManager.shared.ensureSessionActive()
76
-
77
- // Update NowPlaying UI immediately (before download completes)
78
74
  config.isPlaying = true
79
75
  updateNowPlayingInfo()
80
76
  MPNowPlayingInfoCenter.default().playbackState = .playing
81
77
 
82
78
  print("[NowPlayingTemplate] Downloading audio: \(url)")
83
79
 
84
- // Download file first, then play from local — avoids FigFilePlayer streaming errors
80
+ // Download file first, then play from local — R2/Cloudflare CDN streaming
81
+ // causes FigFilePlayer errors with AVPlayer, local playback is reliable
85
82
  downloadTask = URLSession.shared.downloadTask(with: audioURL) { [weak self] tempURL, response, error in
86
83
  guard let self = self else { return }
87
84
 
@@ -100,7 +97,6 @@ class NowPlayingTemplate: AutoPlayTemplate {
100
97
  .appendingPathComponent("carplay_audio_\(UUID().uuidString).mp3")
101
98
 
102
99
  do {
103
- // Remove old file if exists
104
100
  if let oldFile = self.localAudioFileURL {
105
101
  try? FileManager.default.removeItem(at: oldFile)
106
102
  }
@@ -112,7 +108,6 @@ class NowPlayingTemplate: AutoPlayTemplate {
112
108
  return
113
109
  }
114
110
 
115
- // Start playback on main thread
116
111
  DispatchQueue.main.async { [weak self] in
117
112
  self?.startPlaybackFromLocalFile(localURL: localURL, startFrom: self?.pendingStartFrom ?? 0)
118
113
  }
@@ -147,7 +142,6 @@ class NowPlayingTemplate: AutoPlayTemplate {
147
142
 
148
143
  player = AVPlayer(playerItem: playerItem)
149
144
 
150
- // Seek to start position
151
145
  if startFrom > 0 {
152
146
  let time = CMTime(seconds: startFrom, preferredTimescale: 600)
153
147
  player?.seek(to: time)
@@ -179,11 +173,10 @@ class NowPlayingTemplate: AutoPlayTemplate {
179
173
  self?.reportProgress()
180
174
  }
181
175
 
182
- // Play
183
176
  player?.play()
184
177
  MPNowPlayingInfoCenter.default().playbackState = .playing
185
178
 
186
- print("[NowPlayingTemplate] Native audio playback started from local file")
179
+ print("[NowPlayingTemplate] Playback started from local file")
187
180
  }
188
181
 
189
182
  private func handleTimeUpdate(time: CMTime) {
@@ -299,7 +292,6 @@ class NowPlayingTemplate: AutoPlayTemplate {
299
292
  player?.pause()
300
293
  player = nil
301
294
  playerItem = nil
302
- // Clean up temp audio file
303
295
  if let localFile = localAudioFileURL {
304
296
  try? FileManager.default.removeItem(at: localFile)
305
297
  localAudioFileURL = nil
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neoskola/auto-play",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",