mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Still not broken: Next commit decides the fate
This commit is contained in:
parent
cb2afda0f2
commit
dc45c50df4
17 changed files with 1028 additions and 608 deletions
|
|
@ -12,7 +12,8 @@ import SwiftUI
|
|||
class AppleMusicController: MediaControllerProtocol {
|
||||
// MARK: - Properties
|
||||
@Published private var playbackState: PlaybackState = PlaybackState(
|
||||
bundleIdentifier: "com.apple.Music"
|
||||
bundleIdentifier: "com.apple.Music",
|
||||
playbackRate: 1
|
||||
)
|
||||
|
||||
var playbackStatePublisher: AnyPublisher<PlaybackState, Never> {
|
||||
|
|
@ -79,7 +80,8 @@ class AppleMusicController: MediaControllerProtocol {
|
|||
|
||||
func toggleShuffle() async {
|
||||
await executeCommand("set shuffle enabled to not shuffle enabled")
|
||||
playbackState.isShuffled.toggle()
|
||||
try? await Task.sleep(for: .milliseconds(150))
|
||||
await updatePlaybackInfo()
|
||||
}
|
||||
|
||||
func toggleRepeat() async {
|
||||
|
|
@ -92,14 +94,8 @@ class AppleMusicController: MediaControllerProtocol {
|
|||
set song repeat to off
|
||||
end if
|
||||
""")
|
||||
|
||||
if playbackState.repeatMode == .off {
|
||||
playbackState.repeatMode = .all
|
||||
} else if playbackState.repeatMode == .all {
|
||||
playbackState.repeatMode = .one
|
||||
} else {
|
||||
playbackState.repeatMode = .off
|
||||
}
|
||||
try? await Task.sleep(for: .milliseconds(150))
|
||||
await updatePlaybackInfo()
|
||||
}
|
||||
|
||||
func isActive() -> Bool {
|
||||
|
|
@ -122,7 +118,7 @@ class AppleMusicController: MediaControllerProtocol {
|
|||
let repeatModeValue = descriptor.atIndex(8)?.int32Value ?? 0
|
||||
updatedState.repeatMode = RepeatMode(rawValue: Int(repeatModeValue)) ?? .off
|
||||
updatedState.artwork = descriptor.atIndex(9)?.data as Data?
|
||||
|
||||
updatedState.lastUpdated = Date()
|
||||
self.playbackState = updatedState
|
||||
}
|
||||
|
||||
|
|
@ -147,11 +143,11 @@ class AppleMusicController: MediaControllerProtocol {
|
|||
set shuffleState to shuffle enabled
|
||||
set repeatState to song repeat
|
||||
if repeatState is off then
|
||||
set repeatValue to 0
|
||||
else if repeatState is all then
|
||||
set repeatValue to 1
|
||||
else if repeatState is one then
|
||||
set repeatValue to 2
|
||||
else if repeatState is all then
|
||||
set repeatValue to 3
|
||||
end if
|
||||
|
||||
try
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue