mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Fix: Timeline Slider for NowPlaying
This commit is contained in:
parent
be152c1531
commit
022fa187e3
2 changed files with 39 additions and 3 deletions
|
|
@ -134,14 +134,16 @@ final class NowPlayingController: ObservableObject, MediaControllerProtocol {
|
||||||
private func setupNowPlayingObserver() {
|
private func setupNowPlayingObserver() {
|
||||||
let process = Process()
|
let process = Process()
|
||||||
guard
|
guard
|
||||||
let scriptURL = Bundle.main.url(forResource: "mediaremote-adapter", withExtension: "pl"),
|
let scriptURL = Bundle.main.url(forResource: "mediaremote-adapter", withExtension: "pl")
|
||||||
let frameworkPath = Bundle.main.privateFrameworksPath?.appending("/MediaRemoteAdapter.framework")
|
|
||||||
else {
|
else {
|
||||||
print("⚠️ Could not find mediaremote-adapter.pl script or framework path - NowPlaying controller disabled")
|
print("⚠️ Could not find mediaremote-adapter.pl script - NowPlaying controller disabled")
|
||||||
isResourcesAvailable = false
|
isResourcesAvailable = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let bundlePath = Bundle.main.bundlePath
|
||||||
|
let frameworkPath = bundlePath + "/Contents/Frameworks/MediaRemoteAdapter.framework"
|
||||||
|
|
||||||
isResourcesAvailable = true
|
isResourcesAvailable = true
|
||||||
process.executableURL = URL(fileURLWithPath: "/usr/bin/perl")
|
process.executableURL = URL(fileURLWithPath: "/usr/bin/perl")
|
||||||
process.arguments = [scriptURL.path, frameworkPath, "stream"]
|
process.arguments = [scriptURL.path, frameworkPath, "stream"]
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,15 @@ class MusicManager: ObservableObject {
|
||||||
self.bundleIdentifier = state.bundleIdentifier
|
self.bundleIdentifier = state.bundleIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update shuffle and repeat state from controller
|
||||||
|
if state.isShuffled != self.isShuffled {
|
||||||
|
self.isShuffled = state.isShuffled
|
||||||
|
}
|
||||||
|
|
||||||
|
if state.repeatMode != self.repeatMode {
|
||||||
|
self.repeatMode = state.repeatMode
|
||||||
|
}
|
||||||
|
|
||||||
self.timestampDate = state.lastUpdated
|
self.timestampDate = state.lastUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,13 +386,38 @@ class MusicManager: ObservableObject {
|
||||||
|
|
||||||
func toggleShuffle() {
|
func toggleShuffle() {
|
||||||
Task {
|
Task {
|
||||||
|
// Provide immediate UI feedback
|
||||||
|
await MainActor.run {
|
||||||
|
self.isShuffled.toggle()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute the actual command
|
||||||
await activeController?.toggleShuffle()
|
await activeController?.toggleShuffle()
|
||||||
|
|
||||||
|
// Note: The actual state will be updated when the controller reports back
|
||||||
|
// via updateFromPlaybackState if the command provides status feedback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toggleRepeat() {
|
func toggleRepeat() {
|
||||||
Task {
|
Task {
|
||||||
|
// Provide immediate UI feedback
|
||||||
|
await MainActor.run {
|
||||||
|
switch self.repeatMode {
|
||||||
|
case .off:
|
||||||
|
self.repeatMode = .all
|
||||||
|
case .all:
|
||||||
|
self.repeatMode = .one
|
||||||
|
case .one:
|
||||||
|
self.repeatMode = .off
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute the actual command
|
||||||
await activeController?.toggleRepeat()
|
await activeController?.toggleRepeat()
|
||||||
|
|
||||||
|
// Note: The actual state will be updated when the controller reports back
|
||||||
|
// via updateFromPlaybackState if the command provides status feedback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue