feat(mac,ios,playback,store): initial macos implementation
This commit is contained in:
1 parent
e5bb559d7f
commit
d2d7166cf0
72 files changed
+4452
-318
No files matched your search
@@ -52,8 +52,13 @@ public actor PlaybackSession {
|
||||
case let .move(item, after): move(item, after: after)
|
||||
case let .remove(id): state.upcoming.removeAll { $0.id == id }
|
||||
case .clearUpcoming: state.upcoming.removeAll()
|
||||
case .clearHistory: state.history.removeAll()
|
||||
case let .setShuffle(isOn): setShuffle(isOn)
|
||||
case let .setRepeat(mode): state.repeatMode = mode
|
||||
case let .setVolume(volume):
|
||||
guard volume.isFinite else { return }
|
||||
state.volume = min(max(volume, 0), 1)
|
||||
await engine.setVolume(state.volume)
|
||||
}
|
||||
publish()
|
||||
await syncPrepared()
|
||||
@@ -142,12 +147,14 @@ public actor PlaybackSession {
|
||||
private func resume() async {
|
||||
guard state.current != nil, state.status != .playing || state.anchor.rate == 0 else { return }
|
||||
anchor(position, playing: true)
|
||||
publish()
|
||||
await engine.play()
|
||||
}
|
||||
|
||||
private func pause() async {
|
||||
guard state.status == .playing else { return }
|
||||
anchor(position, playing: false)
|
||||
publish()
|
||||
await engine.pause()
|
||||
}
|
||||
|
||||
@@ -155,6 +162,7 @@ public actor PlaybackSession {
|
||||
guard let current = state.current else { return }
|
||||
let clamped = min(max(target, 0), current.track.duration)
|
||||
anchor(clamped, playing: state.status == .playing)
|
||||
publish()
|
||||
await engine.seek(to: clamped)
|
||||
}
|
||||
|
||||
@@ -165,10 +173,15 @@ public actor PlaybackSession {
|
||||
await engine.stop()
|
||||
return
|
||||
}
|
||||
state.anchor = PlaybackAnchor(position: position, instant: now(), rate: 0)
|
||||
state.status = playing ? .playing : .paused
|
||||
publish()
|
||||
await engine.load(current, at: position)
|
||||
anchor(position, playing: playing)
|
||||
if playing {
|
||||
await engine.play()
|
||||
} else {
|
||||
await engine.pause()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user