-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace MPRIS implementation #12
Conversation
The CI build is currently failing because Swift 6 is not available. |
- Removed the old MPRIS implementation. - Integrated a new MPRIS implementation for better performance and compatibility. - Updated relevant code and dependencies to support the new implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while :). The new MPRIS implementation looks brilliant. Here's my suggestion. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not commit unrelated files (also gitignore).
let updatePlayerState: () -> Void = { [weak self] in self?.updatePlayerState() } | ||
disposables.append(try player.player.playbackStatus.observe(updatePlayerState)) | ||
disposables.append(try player.player.metadata.observe(updatePlayerState)) | ||
disposables.append(try player.player.seeked { _ in updatePlayerState() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[weak self]
g_clear_signal_handler(&signal, player) | ||
} | ||
g_object_unref(player) | ||
disposables.forEach { try? $0() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is misleading, we can't just dispose of them, right?
Can you wrap them in DBus library, like this?
class DBusHandlerRegistation {
typealias UnregisterFuction = () throws(DBus.Error) -> Void
let unregister: UnregisterFuction
deinit {
try? unregister()
}
}
} | ||
} | ||
|
||
extension MusicPlayers.MPRIS: MusicPlayerProtocol { | ||
|
||
public var name: MusicPlayerName? { nil } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use bus name? or just .mpris
if not feasible.
/// - instance: The instance name of the media player, if any. | ||
/// - queue: The dispatch queue for the D-Bus method calls. | ||
public convenience init( | ||
name: String, instance: String? = nil, queue: DispatchQueue? = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to make it as simple as possible, treat queue, connection, and timeout as implementation details and don't expose them. We can always expose them later if someone needs it.
guard let manager = playerctl_player_manager_new(nil) else { | ||
return nil | ||
/// Just like `NowPlaying`, but automatically find available MPRIS players. | ||
public final class MPRISNowPlaying: Agent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have player selection logic twice, in different repo. How about deriving from NowPlaying
, only update player list and let NowPlaying
do the selection?
I created the
dbus-swift
andmpris-swift
libraries, providing a newMPRIS
implementation. The new implementation eliminates external dependencies and adds support formacOS
.Changes: