craft-native 0.0.145 → 0.0.146
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.
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/templates/CraftMusic.swift +16 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3303,7 +3303,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3303
3303
|
`);
|
|
3304
3304
|
}
|
|
3305
3305
|
// package.json
|
|
3306
|
-
var version = "0.0.
|
|
3306
|
+
var version = "0.0.146";
|
|
3307
3307
|
|
|
3308
3308
|
// bin/cli.ts
|
|
3309
3309
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -31,6 +31,11 @@ protocol CraftMusicPlayer: AnyObject {
|
|
|
31
31
|
var currentPlaybackTime: TimeInterval { get }
|
|
32
32
|
/// Called on main whenever the song or the playback state changes.
|
|
33
33
|
var onChange: (() -> Void)? { get set }
|
|
34
|
+
/// Sound this player makes that iOS cannot see as another app's: only
|
|
35
|
+
/// the simulator's stand-in, which plays nothing yet should read like
|
|
36
|
+
/// the Music app playing. Read before access is allowed, so the real
|
|
37
|
+
/// player answers false without touching the Music app.
|
|
38
|
+
var soundsLikeOtherAudio: Bool { get }
|
|
34
39
|
func play()
|
|
35
40
|
func pause()
|
|
36
41
|
func skipToNextItem()
|
|
@@ -139,7 +144,7 @@ final class CraftMusic {
|
|
|
139
144
|
var result: [String: Any] = [
|
|
140
145
|
"available": true,
|
|
141
146
|
"authorization": authorization,
|
|
142
|
-
"otherAudioPlaying": AVAudioSession.sharedInstance().isOtherAudioPlaying,
|
|
147
|
+
"otherAudioPlaying": AVAudioSession.sharedInstance().isOtherAudioPlaying || player.soundsLikeOtherAudio,
|
|
143
148
|
"timestamp": Int(Date().timeIntervalSince1970 * 1000),
|
|
144
149
|
"source": NSNull(),
|
|
145
150
|
"playbackState": "unknown",
|
|
@@ -277,6 +282,7 @@ final class CraftMusic {
|
|
|
277
282
|
/// `MPMusicPlayerController.systemMusicPlayer`: the Music app's queue.
|
|
278
283
|
final class CraftSystemMusicPlayer: CraftMusicPlayer {
|
|
279
284
|
let source = "appleMusic"
|
|
285
|
+
let soundsLikeOtherAudio = false
|
|
280
286
|
var onChange: (() -> Void)?
|
|
281
287
|
private var observers: [NSObjectProtocol] = []
|
|
282
288
|
private var player: MPMusicPlayerController { MPMusicPlayerController.systemMusicPlayer }
|
|
@@ -330,8 +336,9 @@ final class CraftSystemMusicPlayer: CraftMusicPlayer {
|
|
|
330
336
|
|
|
331
337
|
// MARK: - The simulator's stand-in
|
|
332
338
|
|
|
333
|
-
/// Three made-up songs that play, pause and skip like the Music
|
|
334
|
-
///
|
|
339
|
+
/// Three made-up songs that play (from launch), pause and skip like the Music
|
|
340
|
+
/// app, and count as other audio while they play, so the
|
|
341
|
+
/// bridge, a page's offer, its bar and its events can be tried in the simulator.
|
|
335
342
|
/// Never used on a device (see `CraftMusic.makePlayer`).
|
|
336
343
|
final class CraftFakeMusicPlayer: CraftMusicPlayer {
|
|
337
344
|
let source = "simulated"
|
|
@@ -344,10 +351,14 @@ final class CraftFakeMusicPlayer: CraftMusicPlayer {
|
|
|
344
351
|
("Cooldown", "Recovery Club", "Easy Days", 187, 0.33),
|
|
345
352
|
]
|
|
346
353
|
private var index = 0
|
|
347
|
-
|
|
354
|
+
/// Playing from the start, as when someone opens the app with music on:
|
|
355
|
+
/// that is what a page offering its controls waits for.
|
|
356
|
+
private var state: MPMusicPlaybackState = .playing
|
|
348
357
|
/// Where the song was when it last started or stopped, and when that was.
|
|
349
358
|
private var offset: TimeInterval = 0
|
|
350
|
-
private var startedAt: Date?
|
|
359
|
+
private var startedAt: Date? = Date()
|
|
360
|
+
|
|
361
|
+
var soundsLikeOtherAudio: Bool { state == .playing }
|
|
351
362
|
|
|
352
363
|
var item: CraftMusicItem? {
|
|
353
364
|
let song = songs[index]
|