mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Use Kingfisher to fetch the notification album art
This commit is contained in:
parent
4322a25b8b
commit
b712a8d00d
@ -8,8 +8,11 @@
|
||||
|
||||
import Foundation
|
||||
import ReSwift
|
||||
import Kingfisher
|
||||
|
||||
class UserNotificationsController {
|
||||
let cache = ImageCache.default
|
||||
|
||||
init() {
|
||||
App.store.subscribe(self) {
|
||||
$0.select { $0.playerState.currentSong }
|
||||
@ -18,18 +21,28 @@ class UserNotificationsController {
|
||||
|
||||
func notifyTrack(_ state: Song?) {
|
||||
guard let currentSong = state,
|
||||
let coverArtFilePath = currentSong.album.coverArtFilePath,
|
||||
let status = App.mpdClient.status,
|
||||
status.state == .playing
|
||||
else { return }
|
||||
//
|
||||
// let coverArtService = CoverArtService(path: currentSong.mpdSong.path, album: currentSong.album)
|
||||
//
|
||||
// coverArtService.fetchBigCoverArt()
|
||||
// .done() {
|
||||
// SongNotifierService(song: currentSong, image: $0)
|
||||
// .deliver()
|
||||
// }
|
||||
// .cauterize()
|
||||
|
||||
let imageURL = URL(fileURLWithPath: coverArtFilePath)
|
||||
let provider = LocalFileImageDataProvider(fileURL: imageURL)
|
||||
_ = KingfisherManager.shared.retrieveImage(
|
||||
with: .provider(provider),
|
||||
options: [
|
||||
.processor(DownsamplingImageProcessor(size: NSSize(width: 180, height: 180))),
|
||||
.scaleFactor(2),
|
||||
]
|
||||
) { result in
|
||||
switch result {
|
||||
case .success(let value):
|
||||
SongNotifierService(song: currentSong, image: value.image)
|
||||
.deliver()
|
||||
case .failure:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,10 +9,6 @@
|
||||
import AppKit
|
||||
import ReSwift
|
||||
|
||||
struct UpdateCurrentCoverArtAction: Action {
|
||||
var coverArt: NSImage?
|
||||
}
|
||||
|
||||
struct UpdateCurrentSongAction: Action {
|
||||
var currentSong: Song?
|
||||
}
|
||||
|
||||
@ -39,9 +39,6 @@ func playerReducer(action: Action, state: PlayerState?) -> PlayerState {
|
||||
case let action as UpdateCurrentSongAction:
|
||||
state.currentSong = action.currentSong
|
||||
|
||||
case let action as UpdateCurrentCoverArtAction:
|
||||
break
|
||||
|
||||
case let action as UpdateElapsedTimeAction:
|
||||
state.elapsedTimeMs = action.elapsedTimeMs
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user